Sub-assembly in assembly

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
Answers 3
DG
DG 2013-09-23 Best Answer
SF
SF 2013-09-23

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

RS
RS 2013-09-23

Thanks Deepak