去评论
距米网-精简版

Inventor ILogic 操作教程汇总

JUMU
2019/02/28 16:52:36
遍历部件生成bom

Dim filename() As String
Dim num() As Integer
Dim count As Integer
Sub aa()
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
ReDim filename(0) As String
ReDim num(0) As Integer
count = 0
Dim oCc As ComponentOccurrence
For Each oCc In oDoc.ComponentDefinition.Occurrences
    Call bb(oCc)
Next
End Sub
Private Sub bb(ByVal oInocc As ComponentOccurrence)
Dim oCcocc As ComponentOccurrence
If oInocc.SubOccurrences.count = 0 Then
    For i = 0 To count
        If oInocc.Definition.Document.DisplayName = filename(i) Then
            num(i) = num(i) + 1
            Exit Sub
        End If
    Next i
    count = count + 1
    ReDim Preserve filename(count)
    ReDim Preserve num(count)
    filename(count) = oInocc.Definition.Document.DisplayName
    num(count) = num(count) + 1
Else
    For Each oCcocc In oInocc.SubOccurrences
        Call bb(oCcocc)
    Next
End If
End Sub