I have problem in showing / hiding solid bodies when I work in a .prt file containing multiple bodies. Suppose I hide 3-4 bodies and apply required commands on other bodies. If I want to show all bodies, I have to go to top of Feature Manager Design Tree and click 2 times on solid bodies to first Hide All & then Show All.
Is there a solution to this so that I can make a keyboard shortcut to this?
Hi Udit,
Open your part and hide some bodies as you want and run this code below. It will show you all hidden bodies.
To add this code to toolbar check SolidWorks API Video Tutorials » 7 Ways To Run A Macro Without the Run Button
Dim swApp As Object
Dim model As ModelDoc2
Dim part As PartDoc
Dim BodyArr As Variant
Dim swBody As Body2
Sub main()
Set swApp = Application.SldWorks
Set model = swApp.ActiveDoc
Set part = model
BodyArr = part.GetBodies2(-1, False)
Dim Cnt As Integer
For Cnt = 0 To UBound(BodyArr)
Set swBody = BodyArr(Cnt)
If Not swBody Is Nothing Then
swBody.HideBody (False)
End If
Next Cnt
End Sub