Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: aurel_e

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

EESignature

(Not an Autodesk Employee)