-1

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');
  • use `OfType` with the right class/interface ... there is nothing connected with your ifc library it just `Enumerable.OfType` ... all you need to do is check library reference and find right interface/class and use it like you use `IfcBuildingElement` – Selvin Oct 24 '22 at 09:01
  • Thanks for the quick reply. Is it possible to get all element classes/Interfaces which are exist in the IFC files? – Vishal Kheni Oct 24 '22 at 09:14
  • *get all elemen* and what is `model.Instances` ... again ... read the docs ... it you wouldn't you will never become a programmer – Selvin Oct 24 '22 at 09:21
  • You're using the xbim toolkit libraries - you should probably state that for the wider audience. The issue is that IfcFlowTerminals are not subclasses of IfcBuildingElement in the IFC schema. Recommend you get familiar with the specifications: https://standards.buildingsmart.org/MVD/RELEASE/IFC4/ADD2_TC1/RV1_2/HTML/link/ifcflowterminal.htm – Andy Ward Nov 03 '22 at 17:37

1 Answers1

0

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.

Andy Ward
  • 324
  • 2
  • 7