Loop each SurfaceBody inside an Assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am attempting to:
1- Ask the user to select two assemblies on the display;
2- Iterate through every SurfaceBody or part inside that first assembly;
3- Compare hole-alignment between those parts and the holes in the second assembly's parts.
However, I am not having success in finding enough study material to explain how to access the subcomponents of an assembly in such a way. Please advise if you can.
My code below, for the user selection of 2 assemblies, plus calling the function:
Dim oAssy1 As ComponentOccurrence
oAssy1 = _invApp.CommandManager.Pick(Inventor.SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select first Assembly")
Dim oAssy2 As ComponentOccurrence
oAssy2 = _invApp.CommandManager.Pick(Inventor.SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select another Assembly to compare")
CheckHolesAlignment_Assys(oAssy1, oAssy2, e)
And the function definition:
Public Sub CheckHolesAlignment_Assys(oAssy1 As Inventor.ComponentOccurrence, oAssy2 As Inventor.ComponentOccurrence, e As DoWorkEventArgs)
Dim oBody1 As Inventor.SurfaceBody
Dim oBody2 As Inventor.SurfaceBody
For Each oBody1 In oAssy1.SurfaceBodies
For Each oBody2 In oAssy2.SurfaceBodies
CheckHolesAlignment_Parts(oBody1, oBody2, e)
MsgBox("Test")
Next
Next
End SubAs you can imagine, the "CheckHolesAlignment_Parts" function inside will check something between two SurfaceBody parts. That part I got covered already.
When running the code as is, the "For" loops basically never run. The ComponentOccurrence oAssy1 (as well as oAssy2) seem empty. 🤔
Thank you for your attention.