ShowAll and Hide Selected Parts Macro
ShowAll and Hide Selected Parts Macro
(OP)
Last year I found a couple of macros on the web. One was for showing all parts of an assembly and the second hid all the selected components in an assembly. I found them very useful when working with large assemblies (or any assembly for that matter). I've recently changed jobs and I'm having no luck locating these macros again. If anyone has any suggestions where I can find macros like this I'd appreciate it. Hiding selected components is relatively easy but being able to click an icon and have everything shown is really nice (especially if the hidden parts are in sub-assemblies).
Thanks,
Killswitch
Thanks,
Killswitch






RE: ShowAll and Hide Selected Parts Macro
CODE
' How to show all components in an assembly
Option Explicit
' The visibility information possible for Components.
Public Enum swComponentVisibilityState_e
swComponentHidden = 0
swComponentVisible = 1
End Enum
Sub SetCompVisib _
( _
swComp As SldWorks.Component2, _
sPadStr As String _
)
Dim vChildArray As Variant
Dim swChildComp As SldWorks.Component2
Dim i As Long
' root component has no name ie empty string
Debug.Print sPadStr & swComp.Name2 & " [" & swComp.Visible & "] --> " & swComp.IGetChildrenCount
swComp.Visible = swComponentVisible
vChildArray = swComp.GetChildren
For i = 0 To UBound(vChildArray)
Set swChildComp = vChildArray(i)
SetCompVisib swChildComp, sPadStr & " "
Next i
End Sub
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swAssy As SldWorks.AssemblyDoc
Dim swConfig As SldWorks.Configuration
Dim swRootComp As SldWorks.Component2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swAssy = swModel
Set swConfig = swAssy.GetActiveConfiguration
Set swRootComp = swConfig.GetRootComponent
Debug.Print "File = " & swModel.GetPathName
SetCompVisib swRootComp, " "
End Sub
'----------------------------------------------------
RE: ShowAll and Hide Selected Parts Macro
Check this one out: Thread559-37101
Look for KenBolen (Mechanical)
Bradley