可用ilogic直接保存运行,代码如下:
Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
Dim oADO As Inventor.ComponentOccurrences = oDoc.ComponentDefinition.Occurrences
Dim ES As String = vbNullString
For Each aDoc As Document In oDoc.AllReferencedDocuments
Dim sFN As String = aDoc.FullFileName
Dim Amount As Integer = oADO.AllReferencedOccurrences(aDoc).Count
Dim oPropsets As PropertySets = aDoc.PropertySets
Dim oPropSet As PropertySet = oPropsets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")
Dim PN As String = oPropSet("Part Number").Expression
If ES <> vbNullString Then ES += vbNewLine
ES += PN & " " & CStr(Amount)
Next
MsgBox(ES)
好东西谢谢分享