Macro delete project geometry in sketch

Macro delete project geometry in sketch

Anonymous
Not applicable
916 Views
4 Replies
Message 1 of 5

Macro delete project geometry in sketch

Anonymous
Not applicable

Hello.

 

I wish to delete all project geometry in the active drawingsketch with 1 click

 

But unsure how to get to these constraints.

 

Are these geometricConstraints?

 

What I have now doesnt work:

 

            
Select Case ThisDoc.Document.DocumentType
Case 12292:
Case Else: MsgBox("Current Document not a drawing document")
Exit Sub
End Select

If Not TypeOf ThisApplication.ActiveEditObject Is Sketch Then
MsgBox("Please activate a sketch")
Exit Sub
End If

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSketch As Inventor.DrawingSketch = ThisApplication.ActiveEditObject

Dim oGeos As GeometricConstraints = OSketch.GeometricConstraints
Dim oGeo As GeometricConstraint
For Each oGeo In oGeos
oGeo.delete
Next

 

What am I doing wrong?

 

 

Thx in advance,

 

Arnold

 

 

 

0 Likes
917 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

you can check if SketchEntity.ReferencedEntity is nothing to see if its referenced geometry, but I'm fairly certian that you cannot delete referenced geometry with SketchEntity.Delete() method.

0 Likes
Message 3 of 5

Anonymous
Not applicable

Yes, I have tried that method, but I also can't find how to delete the projected geometry constraints

0 Likes
Message 4 of 5

philippe.leefsma
Alumni
Alumni

 Hi Arnold,

 

There is no constraints for projected geometry. So as our friend Robert mentioned, iterate through the sketch entities to find the ones that have a ReferencedEntiy, which mean they are projected. Then simply call Delete on those sketch entities.

 

Regards,

Philippe.

______________________________________________________________

If my post answers your question, please click the "Accept as Solution"

button. This helps everyone find answers more quickly!

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 5

rohitchavan123
Participant
Participant
Hi Philippe,

Simply calling delete on sketch entity is giving exception in API.
I tried BreakLink() on sketch also but it also give exception.

Looks like deleting Projected Loop is tricky one.

Regards,
Rohit
0 Likes