Hi everyone I want to make a VBA macro that removes ' edge-on-edge ' sketching relationships and wobbly constraints, such as converting entities, whether it's from an external part or another sketch of the same part
I am in the sketch to be dealt with I run the macro that should check each element to see the type of constraint, if it's ' on edge › delete
I don't know how to select each item 1 by 1 I don't know how to check if it's equal to ' on edge ' or wobbly I don't know how to remove the associated constraint
Here's my macro start
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSketchMgr As SldWorks.SketchManager
Dim swSketch As SldWorks.Sketch
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim nSketchStatus As Long
Dim boolstatus As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSketchMgr = swModel.SketchManager
Set swSketch = swSketchMgr.ActiveSketch
If swSketch Is Nothing Then
MsgBox "Éditer une esquisse et relancer la macro"
Exit Sub
End If
'For i = 1 To Count
'selectionner i element
'if relation existante =sgOFFSETEDGE
'boolstatus = Part.Extension.SelectByID2(xx, , ,, , , )
'swModel.EditDelete
'swModel.SketchManager.SketchConstraintsDel 1, "sgOFFSETEDGE"
'swModel.SketchConstraintsDel i, "sgOFFSETEDGE"
'Next i
swModel.ClearSelection2 True
End Sub
The "SkPoint ID" and "SkSeg ID" are not variables but full text, to display in the debug window the point ID of the sketch (sk → sketch), and SkSeg the ID of the Segment.
You can notice that they are between " ", but above all that these words are not declared (with a dim for example), so cannot be variables.
Hello I didn't have time to test but there are filter criteria on what must scan this code. Basically, it's set to All and depending on the result, you can come across unidentified cases that can be wobbly sketches or other. You would have to set the filter on the elements that are wobbly to make a specific loop on this status. I don't have access to SW at least until the end of the week.