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.

Blog: hjalte.nl - github.com