How to get all faces from Room where walls are in linked file in Revit API

How to get all faces from Room where walls are in linked file in Revit API

Pravin_Lande
Enthusiast Enthusiast
1,825 Views
7 Replies
Message 1 of 8

How to get all faces from Room where walls are in linked file in Revit API

Pravin_Lande
Enthusiast
Enthusiast

Hi 

 

We have room in active document and walls are present in linked file. when we try to get all faces of room we are getting only one face. but we want to get all faces of rooms to get walls, ceiling, floor from linked file.

 

kindly suggest is it possible via Revit API to get all faces of room programmatically.

 

Regards,

Pravin

0 Likes
1,826 Views
7 Replies
Replies (7)
Message 2 of 8

aignatovich
Advisor
Advisor

Hi, take a look at the SpatialElementGeometryCalculator class. You can retrieve room geometry with boundary faces data.

So, firstly call SpatialElementGeometryCalculator.CalculateSpatialElementGeometry method. It returns an instance of SpatialElementGeometryResults class, then you can get a solid from the results, using SpatialElementGeometryResults.GetGeometry method, then for each face of the solid you can retrieve a list of SpatialElementBoundarySubface. It has SpatialBoundaryElement property (LinkElementId), so you can retrieve a boundary element both if it is located in the model or in the linked file.

0 Likes
Message 3 of 8

CristianHarper
Contributor
Contributor

On the GetGeometry() Method is there a way to set references to 'true' so we can place a face-based family on the linked model room wall faces? 

0 Likes
Message 4 of 8

jeremytammik
Autodesk
Autodesk

Dear Pravin,

 

Thank you for your query and many thanks to Alexander for his helpful solution!

 

Another way to address this task might possibly be to ask the room for its closed shell using the Room ClosedShell property and determine the faces from that:

 

https://www.revitapidocs.com/2020/1a510aef-63f6-4d32-c0ff-a8071f5e23b8.htm

 

I do not know whether the room in the linked file will provide this data, nor whether you may need to apply some transformation to it to get it into the current project coordinate system, but it enable a quick and simple solution.

 

The Building Coder offers several samples illustrating its use:

 

https://www.google.com/search?q=closedshell&as_sitesearch=thebuildingcoder.typepad.com

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 8

jeremytammik
Autodesk
Autodesk

@CristianHarper simply set ComputeReferences to true in the Options class passed in to the Geometry property:

 

https://www.revitapidocs.com/2020/d7da6de4-74a9-60e2-826f-698a5730d0a8.htm

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 6 of 8

CristianHarper
Contributor
Contributor

@jeremytammik,

 

The GetGeometry method doesn't accept options correct?

I know there is another get_geometry method that accepts options, but it doesn't work with linked elements.

 

If there is an example the GetGeometry method accepting options can you refer me to it? I have been searching for a couple months now.

0 Likes
Message 7 of 8

jeremytammik
Autodesk
Autodesk

Struggling for months sounds like a good idea if it involves nothing whatsoever but digesting information gradually.

 

Working eight hours a day with no progress sounds like a bad idea.

 

Regardless, maybe you are barking up the wrong tree?

 

Many paths lead to Rome.

 

How about this recent discussion on using the ReferenceIntersector in a linked file?

 

https://thebuildingcoder.typepad.com/blog/2020/05/using-referenceintersector-with-a-linked-file.html

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 8

CristianHarper
Contributor
Contributor

@jeremytammik 

😁 It's a good thing this is a side gig just trying to help out my company's different departments.

 

Definitely looks like I was barking up the wrong tree. I'll give that ReferenceIntersector a try!

 

Thanks for your help

0 Likes