I'm having an issue where I can't add sketch constraints to a selected entity in a sketch with part of a macro I'm writing. Basically this part of my code is supposed to loop through every sketch segment inside of a 3D sketch, deletes all relations, and add a fixed constraint to everything. The loop runs fine selecting each line when I step through it, but when it reaches swModel.SketchAddConstraints ("sgFixed") it just doesn't do anything.
I've tried singling it out to troubleshoot, but still no dice. I can't get any constraints to be added to a selected line even in a fresh sketch with a random line drawn, so I'm guessing its something wrong with the way I'm calling it. Can someone help me out? Pertinent code below.
Sub main()
Dim swApp As SldWorks.SldWorks
Dim Part As Object
Dim swModel As SldWorks.ModelDoc2
Dim swSelectionMgr As SldWorks.SelectionMgr
Dim swSketchMgr As SldWorks.SketchManager
Dim swSketch As SldWorks.Sketch
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSketch = swModel.SketchManager.ActiveSketch
Dim vSegs As Variant
Dim i As Integer
vSegs = swSketch.GetSketchSegments
For i = 0 To UBound(vSegs)
Dim swSkSeg As SldWorks.SketchSegment
Set swSkSeg = vSegs(i)
swSkSeg.Select4 True, Nothing
'swModel.SketchConstraintsDelAll
swModel.SketchAddConstraints ("sgFixed")
swModel.ClearSelection2 True
Next i