Show All Components Example (VBA)
This example shows how to show all of the components in an assembly.
'----------------------------------------------
'
' Preconditions: An assembly is open and one or more components
are hidden.
'
' Postconditions: All assembly components are visible.
'
'----------------------------------------------
Option Explicit
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; it is an 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