Elements intersection with linked model's rooms

Elements intersection with linked model's rooms

Anonymous
Not applicable
1,821 Views
3 Replies
Message 1 of 4

Elements intersection with linked model's rooms

Anonymous
Not applicable

Hi there,

 

I am trying to get all elements that exist(intersects) in a Room that is defined in another(linked) Model.

 

So in the linked model, I have rooms, and I get their geometry with SpatialElementGeometryCalculator and try to intersect with all elements(FamilyInstance) using ElementIntersectsSolidFilter.

 

I am able to retrieve some elements that intersect with the roomSolid, but not all elements. For example, I can get duct fittings but not ducts. Can anybody help me if I'm missing out something? I tried to use Element instead of FamilyInstance, which returned nothing.

 

 

 

 

public List<FamilyInstance> getElementsInTheRoom(Room room)
{
List<FamilyInstance> elementsInTheRoom = new List<FamilyInstance>();
SpatialElementGeometryCalculator calculator = new SpatialElementGeometryCalculator(Global.doc());
SpatialElementGeometryResults results = calculator.CalculateSpatialElementGeometry(room); // compute the room geometry 
Solid roomSolid = results.GetGeometry(); // get the solid representing the room's geometry

elementsInTheRoom = new FilteredElementCollector(Global.doc()).                                            OfClass(typeof(FamilyInstance)).WherePasses(new ElementIntersectsSolidFilter(roomSolid)).Cast<FamilyInstance>().ToList();
}

 

 

 

 

0 Likes
Accepted solutions (1)
1,822 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk
0 Likes
Message 3 of 4

Anonymous
Not applicable

Hello Jeremy, thanks for your response.

 

Actually I don't have an issue with getting the rooms from the linked model. I can turn those rooms into solids. I can even create generic objects with them. But when intersecting them with the FilteredElementCollector by ElementIntersectsSolidFilter  I only get some elements. Not all elements. Is this a bug?  It should be legal to intersect solid geometries with other elements right?

 

Why do you suggest using ReferenceIntersector? Also, Rooms don't have LocationCurve property so I couldn't make it work. How should I proceed? 🙄

 

 

 

 

foreach (Document arcDoc in linkedDocs)
{
if (arcDoc.Title.Contains("ARQ"))
{
FilteredElementCollector linkElementCollector = new FilteredElementCollector(arcDoc);
rooms = new FilteredElementCollector(arcDoc).
                        WhereElementIsNotElementType().
                        OfClass(typeof(SpatialElement)).
                        Where(e => e.GetType() == typeof(Room)).Cast<Room>().ToList();
                }
            }

 

 

 

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution
elementsInTheRoom = new FilteredElementCollector(Global.doc()).WherePasses(filter).ToList();

 

Turns out that there is no need to use "OfClass(typeof(FamilyInstance))" and "Cast<FamilyInstance>()"

0 Likes