how to delete an sketch on 2d drawing on all sheets with ilogic

how to delete an sketch on 2d drawing on all sheets with ilogic

Darkforce_the_ilogic_guy
Advisor Advisor
321 Views
2 Replies
Message 1 of 3

how to delete an sketch on 2d drawing on all sheets with ilogic

Darkforce_the_ilogic_guy
Advisor
Advisor

How does I delete a sketch with I logic on an drawing(idw) with I logic

 

I am working on a code that add an text to a drawing.  and it work ok. but I want to upgraded i a lillte. 

 

to do this I need to delete the old text ( sketch).  That why is will update the text .. if something later is add or change 

 

If the sketch name is "Weld" how do I get my ilogic code to delete it ? If possible on all sheet if there is more then one

0 Likes
Accepted solutions (1)
322 Views
2 Replies
Replies (2)
Message 2 of 3

theo.bot
Collaborator
Collaborator
Accepted solution

You can loop thru all your sheets and try to find your sketch. here a  small sample.

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document 

Dim oSheet As Sheet
Dim oSketch As DrawingSketch

For Each oSheet In oDoc.Sheets
	
	Try
	oSketch = oSheet.Sketches.Item("Weld")
	oSketch.Delete
		Logger.Info("Sketch Weld deleted from Sheet " & oSheet.Name)
	Catch
		Logger.Info("No Sketch Weld found in Sheet " & oSheet.Name)
	End Try
	
	
Next

 

But if you need to update the text value in your sketch you can also update the text in the existing sketch instead of deleting the old one and placing a new one.

Message 3 of 3

Darkforce_the_ilogic_guy
Advisor
Advisor

Hey theo.bot thanks for the help and thanks for teaching me about logs. have not have time to learn that jet .. so thanks for that