Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
vpeuvion
268 Views, 2 Replies

Inventor 2023 : Find the assembly or subassembly that contains the selected part.

Hi,

I'm trying to find the assembly that contains the selected part.

Until now, I use a code where I select a face, from this face, I find the part document and from the part document, I find the assembly document which contains it. I do it following these steps because I need the face and part for other operations. It works well when I only have one assembly open. If another assembly that contains the part is opened, I may end up with the wrong result since I am using item 1.

Is there an easy way to find the assembly or subassembly that contains the selected part?

Attached is a simplified extract of the code : 

Sub Main()
	Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Face")
	If oFace Is Nothing Then Exit Sub
	Dim oPartDoc As PartDocument = oFace.Parent.ComponentDefinition.Document
	Dim oAsm As AssemblyDocument = oPartDoc.ReferencingDocuments.Item(1)
	MessageBox.Show(oAsm.DisplayName)
End Sub

Thanks. Vincent.