Delete a sketch in drawing

Delete a sketch in drawing

shastu
Advisor Advisor
423 Views
2 Replies
Message 1 of 3

Delete a sketch in drawing

shastu
Advisor
Advisor

This I would think would be so easy.  I don't need a for loop as the sketch I am trying to delete in VBA is not tied to any view, but rather just a general sketch on the drawing.  The name of the sketch is "Sketch1".  Why doesn't the below code work?

 

Dim oApp As Inventor.Application
Set oApp = ThisApplication
Set odoc = oApp.ActiveDocument
Dim oSheet As Sheet
Dim oSketch As DrawingSketch
Set DrawingSketch = "Sketch1"

oSketch.Delete

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

WCrihfield
Mentor
Mentor
Accepted solution

Hi @shastu.  I think it's just missing a couple steps.  Here, try this version, and see if it works better for you:

Sub DeleteDrawingSketch()
    Dim oApp As Inventor.Application
    Set oApp = ThisApplication
    Dim oDDoc As DrawingDocument
    Set oDDoc = oApp.ActiveDocument
    Dim oSheet As Sheet
    Set oSheet = oDDoc.ActiveSheet
    Dim oSketch As DrawingSketch
    Set oSketch = oSheet.Sketches.Item("Sketch1")
    oSketch.Delete
End Sub

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

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

shastu
Advisor
Advisor

Thanks

0 Likes