Hi,
Thanks for your feedback.
I have something put together, but there is one major problem. I'm using this code as a base:
Public Sub TraverseAssemblySample()
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Debug.Print oAsmDoc.DisplayName
' Call the function that does the recursion.
Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences, 1)
End Sub
Private Sub TraverseAssembly(Occurrences As ComponentOccurrences, _
Level As Integer)
' Iterate through all of the occurrence in this collection. This
' represents the occurrences at the top level of an assembly.
Dim oOcc As ComponentOccurrence
For Each oOcc In Occurrences
' Print the name of the current occurrence.
Debug.Print Space(Level * 3) & oOcc.Name
' Check to see if this occurrence represents a subassembly
' and recursively call this function to traverse through it.
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call TraverseAssembly(oOcc.SubOccurrences, Level + 1)
End If
Next
End Sub
The problem is that once it reaches an assembly occurrence, it starts traversing that assembly.
What I need is the code to traverse one entire assembly, count the subassemblies and they traverse them one by one and so on...
Autodesk Inventor 2015 Certified Professional