I am working on a macro to split a face, and read through the documentation on the InsertSplitLineProject method. It says that you have to use SelectByID2 with certain marks to actually get the split line to work. I know that selecting faces with the SelectByID2 method is a PITA, is there another way to add marks and still get InsertSplitLineProject to work?
It appears that at least with my version of SolidWorks (2016 SP5.0), the InsertSplitLineProject function requires that the entities be selected with the SelectByID2 function. I had tried iterating through functions as you can see below and selecting the entity once found. I verified that they highlighted correctly in my view window but the split line function never succeeded with that selection method.
I named my face on my part "That_Face" and used "Sketch4" as my split line to project. I commented out the lines below that select the faces the way I wanted to do it and replaced them with their SelectByID2 counterpart and the split worked as intended.
If someone else can shed more light on this, I would also be interested in a solution after taking a look at this.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim swEnt As SldWorks.Entity
Dim swFace2 As SldWorks.Face2
Dim vBodies As Variant
Dim swBody As SldWorks.Body2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swPart = swModel
vBodies = swPart.GetBodies2(swSolidBody, False)
Set swBody = vBodies(0)
Set swFace2 = swBody.GetFirstFace
swModel.ClearSelection2 True
swModel.Extension.SelectByID2 "Sketch5", "SKETCH", 0, 0, 0, False, 4, Nothing, 0
'swModel.SelectByName 0, "Sketch4"
Do While Not swFace2 Is Nothing
If swModel.GetEntityName(swFace2) = "That_Face" Then
Set swEnt = swFace2
swModel.Extension.SelectByID2 "", "FACE", 4.79295511889791E-03, 7.54999999998063E-03, -1.90909725465572E-02, True, 1, Nothing, 0
'swEnt.Select (True)
End If
Set swFace2 = swFace2.GetNextFace
Loop
swModel.InsertSplitLineProject False, False
End Sub