AnsweredAssumed Answered

Macro BOM

Question asked by Rik Bargeman on Sep 17, 2009
Latest reply on Sep 17, 2009 by Josh Brady

Hello, Im working on a Macro based BOM.

 

Im using:  Component2.GetChildren()  to get the children components from the assembly.

The order of the Child Components in the variant are a little out of place.

 

My question is.. Does someone have a routine to get the child components in the order of the FeatureManager design tree?

 

This is my first question on this forum so any suggestions tor improve any result in the future are welcome.

 

-----------------------

 

Example of my problem:

 

the following macro will give the following result:

'

Dim swApp   As Object
Dim Child   As Object
Dim i As Integer
Dim Children    As Variant
Dim Omschrijving As String


Sub main()


Set ModDoc = Component2.GetModelDoc

Set swApp = Application.SldWorks
Set ModelDoc2 = swApp.ActiveDoc
Set Configuration = ModelDoc2.GetActiveConfiguration
Set Component2 = Configuration.GetRootComponent
Set ModDoc = Component2.GetModelDoc


Children = Component2.GetChildren()
ChildCount = UBound(Children) + 1

i = 0

Do While i <> ChildCount
Set Component2 = Children(i)
Set ModDoc = Component2.GetModelDoc
Omschrijvingen = Omschrijvingen & ModDoc.CustomInfo2("", "DESCRIPTION") & vbNewLine
i = i + 1
Loop

MsgBox Omschrijvingen, vbOKOnly
End Sub

'resultaat.JPG

As you can see the first components of the design tree are not the same as the first in my msgBox. How is that posible????

Outcomes