How to get the host face of an instance if the host face is from linked document?

How to get the host face of an instance if the host face is from linked document?

grubdex
Enthusiast Enthusiast
668 Views
4 Replies
Message 1 of 5

How to get the host face of an instance if the host face is from linked document?

grubdex
Enthusiast
Enthusiast

I'm wondering how I can get the host face of a family instance that is hosted to a face coming from a linked document?

In such cases, the Host is set to the linked Element, and if I use the hostFace.LinkedElementId Id, I'm - as the name implies - some kind of Element (Material, DirectShape,Wall,...). But I would want to get the actual face. How would I achieve that?

 

I tried using the reference living in instance.HostFace directly (both on the main and the linked document), but that didn't work.

grubdex_0-1717771711371.pnggrubdex_1-1717771724937.png

grubdex_2-1717771793108.png

 

 

 

0 Likes
669 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

You can query the element in the linked file for its geometry. To do so, you probably need to determine its host Document and use the LinkedElementId to open the element in that document.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 5

Moustafa_K
Collaborator
Collaborator

see if this explanation helps, it is also aligned to what @jeremy_tammik mentioned

 

In short: to get the host face of a family instance that is hosted to a face from a linked document, you can follow these steps:

1. Retrieve the Host Face Reference: Access the `HostFace` property of the family instance to get the reference to the host face.

2. Get the Linked Document: Use the `LinkedElementId` to find the corresponding linked document and element.

3. Resolve the Linked Face: Use the `Document.GetElement` method with the `LinkedElementId` to obtain the element from the linked document.

4. Get Geometry from the Linked Element: Extract the geometry from the linked element using the `GeometryElement` method.

5. Match the Reference: Compare the reference obtained in step 1 with the faces of the geometry extracted to identify the exact face.

 

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes
Message 4 of 5

grubdex
Enthusiast
Enthusiast

Thanks for the detailing the steps to get there! What would I use to do the matching you suggested in Step 5? Which property do both the geometry face as well as the HostFace reference have in common?

0 Likes
Message 5 of 5

Moustafa_K
Collaborator
Collaborator

Have placed a sample code over here.

Try it and let us know your findings. Basically i am converting to string and comapring strings

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes