AnsweredAssumed Answered

Indented BOM array

Question asked by Robert McCutcheon on Jul 3, 2019
Latest reply on Jul 24, 2019 by Jennifer Farrar

I am trying to generate a list of all parts/sub-assemblies/sub-assembly parts/etc using the api. basically trying to generate an indented BOM. I can get all the top level components but i am stuck on how to dig deeper. Please see my code below.


            Dim SWMODEL As ModelDoc2 = swApp.ActiveDoc
            Dim assemCHILD, MODELpn, MODELprt As Object
            Dim chString(), asstring() As String
            Dim CHILDNAME, assemname As String
            Dim i As Integer
            Dim errors As Integer

            If SWMODEL IsNot Nothing Then
                Dim MODELTYPE As Integer = SWMODEL.GetType
                Dim modeltitle As String = SWMODEL.GetTitle
                Dim modelpath As String = SWMODEL.GetPathName
                modeltitle = Replace(modeltitle, "_", ".")
                asstring = Split(modeltitle, ".")
                assemname = asstring(0)
                pathstring = Split(modelpath, "\")
                MODELpn = assemname
                'gets assembly child part names and qtys
                If MODELTYPE = 2 Then
                    Dim SWASSEM As AssemblyDoc = SWMODEL
                    errors = SWASSEM.ResolveAllLightWeightComponents(True)
                    assemCHILD = SWASSEM.GetComponents(True)
                    For i = LBound(assemCHILD) To UBound(assemCHILD)                       
                        MODELprt = assemCHILD(i).GetModelDoc2
                    Next i
                End If
            End If


        Catch ex As Exception


        End Try