CAFM-Connect / Ifc.NET

Simple c# classes to read and write an File in Format IFC 4 XML
GNU General Public License v3.0
12 stars 4 forks source link

IfcPropertySetTemplate #6

Open thoffeller opened 5 years ago

thoffeller commented 5 years ago

Hi, how do I retrieve the IfcPropertySetTemplate's from bim-profiles? In document.GetIfcPropertySetTemplateCollection(...) I need to provide a ccFacility, but the facilities collection of the doc is empty...

Is there a generic way to retrieve any object via its id? Thanks!

thoffeller commented 5 years ago

There is a generic Add available. Generic get, too?

thoffeller commented 5 years ago

Ahh, ok, found somthing in the source in Document.cs : internal Dictionary<string, Ifc4.IfcPropertySetTemplate> IfcPropertySetTemplateCollection But it seems not to be avialable in nuget package.

klacol commented 5 years ago

Does that work?

foreach (var ifcPropertySetTemplate in document.IfcXmlDocument.Items.OfType<IfcPropertySetTemplate>())
  {
      foreach (IfcPropertyTemplate ifcPropertyTemplate in ifcPropertySetTemplate.HasPropertyTemplates.Items)
      //do something
  }
thoffeller commented 5 years ago

yes, implemented it already this way. But how should the method on top be used? or should it be removed?

klacol commented 5 years ago

I think, it should be removed. It is stuff that is more related to CAFM-Connect, than to standard IFC. Sort of helper classes.

Jo64 commented 5 years ago

You need the CcFacility class only when you want to write a CafmConnect file. In the first level an IfcSystem object must be created and the next levels are of type IfcObjectDefinition.

CcFacility groupFacility = document.Project.Facilities.AddNewSystem(document.Project);
groupFacility.IfcSystem.Name = "Group01";

CcFacility facility = groupFacility.Facilities.AddNewFacility();
// the default facility.IfcObjectDefinition is an IfcBuildingElementProxy object
// if you want to change this you can set the 
facility.ObjectTypeId = /*e.g.*/ "i2139"; // or an Id from a IfcClassificationReference

This is a facility object you can pass to the GetIfcPropertySetTemplateCollection function. Or if you know the IfcPropertySetTemplate Id value.

var ifcPropertySetTemplate = document.IfcXmlDocument.Items.OfType<IfcPropertySetTemplate>().FirstOrDefault(item => item.Id == /*e.g.*/"i30425");