
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create code to delete all of the circle geometry in a given sketch. The code I have works... sort of.
Dim oPD As PartDocument oPD = ThisApplication.ActiveDocument Dim oCD As ComponentDefinition oCD = oPD.ComponentDefinition Dim oS As PlanarSketch oS = oCD.Sketches.Item("HOLE SKETCH") Dim oSC As SketchCircle For i = 1 To HOLES oSC = oS.SketchCircles.Item(i) oSC.Delete MessageBox.Show("Hole " & i & " deleted", "Note") Next
The strange behavior I have noticed is that this bit of code seems to skip every second instance. For example if I create a row of circles, the first one is deleted, then it deletes the third one and says the second is deleted, then the 5th one etc. When it gets to the end of the half deleted row of circles it then errors out letting me know that it couldn't find any more.
Why is this happening? Am I doing something wrong?
If I set this rule to delete just one circle, and then create another rule to trigger this rule for however many circles exist, then everything works fine. But I still feel like I am doing something wrong with this band-aid approach.
Solved! Go to Solution.