- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS
or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)