Hi all
I'm a beginner on SW, and I'm interested in creating macros for trajectory construction.
I try to reproduce as faithfully as possible the trajectory of an industrial knitting yarn. The trajectory passes through 4 points and lines and splines are used for its construction.
Thanks to macro recording, I was able to retrieve the script necessary to create points, build lines as well as splines.
However, I need to have control over the tangents of the start and end points (which are calculated). Unfortunately, when I use macro recording and build the spline with tangent driving, I don't see any new "function" appear.
Is it possible to recover this function?
Here is the save script that I got after manual construction (there are probably some unnecessary lines left):
Partial Class SolidWorksMacro
Public Sub main()
Dim swDoc As ModelDoc2 = Nothing
Dim swPart As PartDoc = Nothing
Dim swDrawing As DrawingDoc = Nothing
Dim swAssembly As AssemblyDoc = Nothing
Dim boolstatus As Boolean = false
Dim longstatus as integer = 0
Dim longwarnings as integer = 0
swDoc = CType(swApp.ActiveDoc,ModelDoc2)
swDoc.SketchManager.Insert3DSketch(true)
'
Dim skSegment As SketchSegment = Nothing
skSegment = CType(swDoc.SketchManager.CreateLine(0.000000, 0.000000, 0.000000, -0.002000, 0.004000, -0.000500),SketchSegment)
swDoc.SetPickMode()
swDoc.ClearSelection2(true)
'
Dim pointArray As Array = Nothing
Dim points(8) Ace Double
points(0) = -0.002
points(1) = 0.004
points(2) = -0.0005
points(3) = 0.004
points(4) = 0.008
points(5) = -0.0015
points(6) = 0.016
points(7) = 0.009
points(8) = -0.002
pointArray = points
skSegment = CType(swDoc.SketchManager.CreateSpline(pointArray),SketchSegment)
boolstatus = swDoc.Extension.SelectByID2("Spline1", "SKETCHSEGMENT", 0.0, 0.0, 0, False, 0, Nothing, 0)
swDoc.ShowNamedView2("*Left", 3)
swDoc.ClearSelection2(true)
swDoc.EditUndo2(1)
boolstatus = swDoc.Extension.SelectByID2("Spline1", "SKETCHSEGMENT", 0.0070000000000000000062, 0.0060299676105561159, -0.0010150801486359592, false, 0, Nothing, 0)
swDoc.ShowNamedView2("*Face", 1)
swDoc.ShowNamedView2("*Left", 3)
swDoc.ClearSelection2(true)
swDoc.EditUndo2(1)
boolstatus = swDoc.Extension.SelectByID2("Spline1", "SKETCHSEGMENT", 0.006999999999999999984, 0.0049025748626198599, -0.00080798849755920818, false, 0, Nothing, 0)
swDoc.ShowNamedView2("*Face", 1)
swDoc.ClearSelection2(true)
swDoc.SketchManager.Insert3DSketch(true)
End Sub
''' <summary>
''' The SldWorks swApp variable is pre-assigned for you.
''' </summary>
Public swApp As SldWorks
End Class
Thanks again