I have found this:
https://resources.imaginit.com/manufacturing-solutions-blog/traversing-assembly-structure-with-ilogi...
I was really happy when I saw recursion meaning that all of the parts are in one tree and if so I could be able to enter the child rigth?
The code should be something like:
Sub Main
' Get the active assembly.
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument
' Call the function
Call TraverseAssembly(oAssyDoc.ComponentDefinition.Occurrences)
End Sub
Sub TraverseAssembly(oOccs As ComponentOccurrences)
' Iterate through all of the occurrence in this collection
Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
' See each component
MessageBox.Show(oOcc.Name, "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
'it's a hole save diameter
' find the bolts or screws outside and do a comparation between bolt diameter and hole
If iProperties.Value(oOcc.Name, "Project", "Description").Contains("bolt") Or iProperties.Value(oOcc.Name, "Project", "Description").Contains("Bolt") Or iProperties.Value(oOcc.Name, "Project", "Description").Contains("screw") Or iProperties.Value(oOcc.Name, "Project", "Description").Contains("Screw") Then
'Notify user that they are different
My_Message0 = "O diâmetro do parafuso e do furo são diferente." + vbLf + "Deseja fazer a correção?"
inputUser = MessageBox.Show(My_Message0, "Erro Detetado", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)
'Show the option to change, add to log or stop rule
If inputUser = 6 Then '''Yes - change the Hole diameter
MessageBox.Show(inputUser, "Yes", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
ElseIf inputUser = 7 'No - creat a log saying that the HoleN wasn't change
MessageBox.Show(inputUser, "No", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
Else 'Cancel - Stop Everything and Exit Rule
My_Message1 = "A execução da rule foi cancelada." + vbLf + "A parar a execução..."
MessageBox.Show(My_Message1, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
End If
End If
' Recursively call sub if needed
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call TraverseAssembly(oOcc.SubOccurrences)
MessageBox.Show("Aqui")
End If
Next
End Sub