Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
hieut1392
in reply to: WCrihfield

I stumbled upon your code in this post, it does exactly what I wanted.

 

https://forums.autodesk.com/t5/inventor-programming-ilogic/hide-all-other-solid-keep-selected-visibi...

 

I edited it a bit, the vba code is below for those who need it.

 

 

Sub Main()
    Dim oObj As Object
    Set oObj = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Select a Drawing View.")
    Dim oView As DrawingView
    Set oView = oObj
    Dim oModelDoc As Document
    Set oModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
    Dim oPDoc As PartDocument
    Set oPDoc = oModelDoc
    Dim oBodies As SurfaceBodies
    Set oBodies = oPDoc.ComponentDefinition.SurfaceBodies
    Dim oBodyNames As Collection
    Set oBodyNames = New Collection
    Dim oBody As SurfaceBody
    For Each oBody In oBodies
        oBodyNames.Add oBody.name
    Next
    Dim oBodyName As String
    oBodyName = InputBox("Body Names = ", "Input A Body Name", "P")
    If oBodyName = "" Then Exit Sub
    For Each oBody In oBodies
        If oBody.name <> oBodyName Then
            oView.SetVisibility oBody, False
        End If
    Next
    oView.Parent.Update 'update the sheet
    oView.Parent.Parent.Update ' update the drawing
End Sub