11-26-2024
02:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-26-2024
02:28 AM
I stumbled upon your code in this post, it does exactly what I wanted.
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