01-04-2024
09:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-04-2024
09:36 AM
Here is the version with the list and FullFileName check included, just in case that is what you need, due to ModelStates. If the referenced document is an assembly, and its FullFileName has not yet been added to the list, then we add its FullFileName to the list, and count it. If its FullFileName is already in the list, then it will not get counted.
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Return
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oRefDocs As DocumentsEnumerator = oADoc.AllReferencedDocuments
Dim oList As New List(Of String)
Dim iCount As Integer = 0
For Each oRefDoc As Inventor.Document In oRefDocs
If oRefDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
If oList.Contains(oRefDoc.FullFileName) = False Then
oList.Add(oRefDoc.FullFileName)
iCount = iCount + 1
End If
End If
Next
MsgBox("There are " & iCount & " unique sub assemblies in this assembly.", vbInformation, "iLogic")
End Sub
Wesley Crihfield
(Not an Autodesk Employee)