I use the following code, to rtaverse all components, of a specific assembly:
swAssemblyModel = swApp.ActiveDoc
swConf = swAssemblyModel.GetActiveConfiguration
swRootComp = swConf.GetRootComponent3(True)
vChildComp = swRootComp.GetChildren
For i = 0 To UBound(vChildComp)
swComp = vChildComp(i)
...
...
...
Next i
I have noticed "IsSuppressed", or "IsPatternInstance" parametars, which defines component's suppression-state and patteren-state, for example.
Is there a way to define if any component is a sub-assembly, in the assembly, and get its children also?
SolidworksApi macros
Check this API example: Traverse Assembly at Component Level Example (VBA)
Private Sub Traverse(ByVal swModel2 As ModelDoc2)
Dim swAssy As AssemblyDoc
Dim vComps As Variant
Dim swSubModel As ModelDoc2
Set swAssy = swModel2
vComps = swAssy.GetComponents(True)
For i = 0 To UBound(vComps)
Set swSubModel = vComps(i).GetModelDoc2
If (swSubModel.GetType = swDocumentTypes_e.swDocASSEMBLY) Then Call Traverse(swSubModel)
....
Message was edited by: Tapani Sjoman
Thanks Deepak