Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
J-Camper
in reply to: wgraham

I found a way using CommandManager to replicate the UI command "DeleteConstraints".  Sketch Enties that are part of a sick Projected Loop can't be deleted until their constraints are deleted.  You need to do this all at once though because if you delete constraints from part of the loop, the rest of the sketch entities in that loop are no longer sick and won't get picked up/Deleted by the rule.

 

Try this out:

Dim oPartDoc As PartDocument = ThisDoc.Document 
Dim deleteConstraintsCMD As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("SketchDeleteConstraintsCtxCmd")
Dim sickCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim selSet As SelectSet = oPartDoc.SelectSet

Dim oTrans As Transaction = ThisApplication.TransactionManager.StartTransaction(oPartDoc, "Delete Sick Sketch Entities")
On Error GoTo ERRR
For Each oSketch As PlanarSketch In oPartDoc.ComponentDefinition.Sketches
	selSet.Clear
    oSketch.Edit
    For Each oSketchEnt As SketchEntity In oSketch.SketchEntities
        If oSketchEnt.Reference = True Then
            If oSketchEnt.ReferencedEntity Is Nothing Then
                If Not oSketchEnt.Type = kSketchPointObject Then
					'Collect all sick entities
                    sickCollection.Add(oSketchEnt)
                End If
            End If
        End If
    Next
	'Select All Sick Entities
	selSet.SelectMultiple(sickCollection)
	'Delete All constraints on selected entities
	deleteConstraintsCMD.Execute
	'Loop through and delete all previously sick entities
	For Each Item In sickCollection
		Item.Delete
	Next
    oSketch.ExitEdit
Next
oTrans.End
Exit Sub
ERRR :
	oTrans.Abort
	Logger.Trace("Failure")

 

Let me know if you have any questions, or if this is not working as intended.