Topsolid online Help Index
This example shows how to get a BOM of an assembly.
Dim TopDoc As TopSolid.DocumentDesign
Dim TopElt As TopSolid.Element
Dim TopBom As TopSolid.BOM
Dim TopBomLevel As TopSolid.BOMLevel
Dim i As Integer
On Error Resume Next
' Get the element $SET
Set TopElt = TopDoc3D.Assembly.Element
' Get the bom with the bom model 'NbDesRef.bom'
Set TopBom = TopDoc3D.Document.GetBOM(TopElt, "d:\Missler\V66\bin\NbDesRef.bom")
For i = 1 To TopBom.SubLevels.Count
Set TopBomLevel = TopBom.SubLevels.Item(i)
BomGetShapes TopBomLevel
Next i
Private Sub BomGetShapes(TopBomLevel As TopSolid.BOMLevel)
Dim i As Integer
Dim TopBomSubLevel As TopSolid.BOMLevel
Dim TopShapes As Variant
Dim TopShapeCount As Long
Dim TopShape As TopSolid.Shape
Dim TopShapeName As String
On Error Resume Next
If TopBomLevel.SubLevels.Count <> 0 Then
' if there are sublevels, we get them
For i = 1 To TopBomLevel.SubLevels.Count
Set TopBomSubLevel = TopBomLevel.SubLevels.Item(i)
BomGetShapes TopBomSubLevel
Next i
Else
' if there are no sublevels, we can get the shapes of the sublevel and analyze them
TopShapes = TopBomLevel.GetShapes
TopShapeCount = UBound(TopShapes, 1)
For i = 0 To TopShapeCount
Set TopShape = TopShapes(i)
If TopShape Is Nothing Then
' error management
' it isn't normal
Exit Sub
End If
' what you want to do with the shape
...
Next i
End If
End Sub
Topsolid online Help Index