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

Hi @aurel_e.  Something like this maybe?  If there are multiple of the same sub assembly within the main assembly, and it has multiple ModelStates, and some of those component instances are set to different ModelStates, then this code might need to also include a List(Of String) to keep track of each document's FullFileName while checking.  The FullDocumentName will include the name of the ModelState, so that would not be a good choice, depending on your needs.

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Return
	Dim oADoc As AssemblyDocument = ThisDoc.Document
	Dim oRefDocs As DocumentsEnumerator = oADoc.AllReferencedDocuments
	Dim iCount As Integer = 0
	For Each oRefDoc As Inventor.Document In oRefDocs
		If oRefDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			iCount = iCount + 1
		End If
	Next
	MsgBox("There are " & iCount & " unique sub assemblies in this assembly.", vbInformation, "iLogic")
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)