Get model sketch

Get model sketch

madstrolle
Enthusiast Enthusiast
604 Views
2 Replies
Message 1 of 3

Get model sketch

madstrolle
Enthusiast
Enthusiast

Hello,

 

I have looked for a way to get model sketches to my part file in a drawing.

I found this blog, which is exactly what i'm looking for (code is in the article): 

https://www.symetri.co.uk/insights/blog/autodesk-inventor-2017-ilogic-identify-parts-in-layout-drawi... 

Unfortunately i can't get it to work☹️

Maybe it's because this code is made for assemblies? I'm green when it comes to Ilogic coding 🙃

Is there anybody out there that can help me with this? 

 

Thanks in advance 🙂

 

 

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

JelteDeJong
Mentor
Mentor
Accepted solution

I'm not so sure how useful this is for drawings of part files. but her you go:

Dim Title As String = "Excitech iLogic"
Dim Counter As Integer = 0
Dim SketchName As String = "Sketch 1"


Dim doc As DrawingDocument = ThisDoc.Document
Dim view As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a view to toggle sketch visibility, or hit ESC to cancel...")

If view Is Nothing Then
    Exit Sub
End If

SketchName = InputBox("Please enter name of sketch to toggle visibility.", Title, SketchName)

Dim refDoc As PartDocument = view.ReferencedDocumentDescriptor.ReferencedDocument
If refDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
    MsgBox("The referenced document needs to be an part. Exiting", MsgBoxStyle.OkOnly, Title)
    Exit Sub
End If

Dim def As PartComponentDefinition = refDoc.ComponentDefinition
Dim sketches As PlanarSketches = def.Sketches

For Each sketch As PlanarSketch In sketches
    If Sketch.Name = SketchName Then
        Counter += 1

        Dim current As Boolean = view.GetIncludeStatus(Sketch)
        view.SetIncludeStatus(Sketch, Not current)


    End If
Next

If Counter = 0 Then
    MsgBox("No sketches called " & SketchName & " were found in this view.", MsgBoxStyle.OkOnly, Title)
End If

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 3

madstrolle
Enthusiast
Enthusiast
Working perfect.
Thank you 🙂
0 Likes