How to get all the elements from the .ifc file?

599 views Asked by At

I would like to Extract all the elements from the IFC file. here is my code snippet

var allElements = model.Instances.OfType<IfcBuildingElement>().ToList();

from the above code, I can extract all walls, windows, etc but my IFC file also contains Flow fitting, flow segment, etc. can you please guide me how I can extract these elements as well here is my IFC file snippet

#800=IFCFLOWSEGMENT('2n8o7Tjz5F1hq6D4q35mMw',#42,'Rund:Luftkanal - T-St\X\FCck:7596625',$,'Rund:Luftkanal - T-St\X\FCck',#760,#784,'7596625');
#1123=IFCFLOWSEGMENT('2n8o7Tjz5F1hq6D4q35mMC',#42,'Oval:Luftkanal - Stutzen:7596647',$,'Oval:Luftkanal - Stutzen',#1049,#1119,'7596647');
#1895=IFCFLOWFITTING('2n8o7Tjz5F1hq6D4q35mJZ',#42,'Luftkanal - Sattelstutzen oval:Standard:7596808',$,'Luftkanal - Sattelstutzen oval:Standard',#1894,#1888,'7596808');
#3728=IFCFLOWFITTING('2n8o7Tjz5F1hq6D4q35mJu',#42,'Luftkanal - Bogen oval Segment:Standard:7596819',$,'Luftkanal - Bogen oval Segment:Standard',#3727,#3721,'7596819');
1

There are 1 answers

0
Andy Ward On

In the xbim library, OfType<T>() filters the model instances, returning those that implement the type, by building a query against the underlying model store.

Your code is enumerating all instances that are OfType<IfcBuildingElement>(). i.e. you're filtering out everything but a small hierarchy of the building model's graph.

An IfcBuildingElement is defined as all elements that are primarily part of the construction of a building, i.e., its structural and space separating system. Building elements are all physically existent and tangible things - i.e. Walls, Windows, Beams etc. but not Flow Fittings/Segments (which are under IfcDistributionElement)

If you want to get all physical elements in a model just identify the appropriate ancestor in the hierarchy. I'd start with IfcProduct, or IfcElement. If that's too broad you can always union together multiple IEnumerables.

If you don't use the OfType<T>() filter on model.Instances you'll really get everything in the model, which includes lots of abstract concepts such as relationships, representation etc.