Hey all,
I have a standalone VB.NET program. This program draws some complex geometric shapes. Currently, the program will draw a part, save the part, open an assembly, insert the part into an assembly. I am having problems with the next step. I insert a second part into the assembly, and I want to select sketch segments on the first part, use the convert entities command to copy them to another plane on the second part. I can do this via manual selection and using the UI, but I cannot get it working via the API. I am trying to use the persistent ids of the sketch segments to select them, however the IDs of the same sketch segments differ between the part and the assembly, so instead of selecting the segment in the assembly, my program selects the segments within the part file.
How can I track these part segments once the part is inserted into an assembly?
Below is a simplified macro illustrating what I want to happen.
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As LongSub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("Front", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateArc(-0.018567, -0.023782, 0#, -0.054959, -0.021634, 0#, -0.01447, 0.012442, 0#, 1)
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("Front", "PLANE", 0, 0, 0, True, 0, Nothing, 0)
Dim myRefPlane As Object
Set myRefPlane = Part.CreatePlaneAtOffset3(0.28194, False, True)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Plane1", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.ViewZoomtofit2
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("Arc1@Sketch1", "EXTSKETCHSEGMENT", 0.006226102698241, 0.002943771101859, 0, False, 0, Nothing, 0)
boolstatus = Part.SketchUseEdge2(False)
End Sub
Thanks.
SolidworksApi macros