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

I tried this before too.  After checking that the 'Reference' boolean is True, and that the 'ReferencedEntity' was nothing, I then entered into Edit mode for the sketch, then used a Try...Catch block of code around my 'Delete' method, to avoid the expected errors.  When I put a MsgBox in the Catch portion, it would show that MsgBox some times, but the 'sick' projected geometry was gone when the rule finished, so it did do it's job for me.  I didn't bother trying to set the 'Reference' property to False, because the geometry object is already in an error state.

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
For Each oSketch As PlanarSketch In oPDef.Sketches
	For Each oSE As SketchEntity In oSketch.SketchEntities
		If oSE.Reference Then
			If oSE.ReferencedEntity Is Nothing Then
				oSketch.Edit
				Try
					oSE.Delete
				Catch
					'MsgBox("Couldn't delete it.", , "")
				End Try
				oSketch.ExitEdit
			End If
		End If
	Next
Next

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)