Adding Element to IfcBuilding in IFC2x3
Hello, xBim team! How can I add Element to IfcBuilding in IFC2x3? There is no building.AddElement() method in Xbim.Ifc2x3.ProductExtension.IfcBuilding. Thanks!
You can just use IfcRelContainedInSpatialStructure or IfcRelReferencedInSpatialStructure directly.
Can you give some code sample please?
Hello @GVladislavG ,
You would have to create the relational objects that you need according to the IFC schema.
var newRel = model.Instances.New<IfcRelContainedInSpatialStructure>();
Then set the properties of the newRel to create the hierarchy that you need.
I do such steps
var bldElProxyIfc2x3= model.Instances.New<Xbim.Ifc2x3.ProductExtension.IfcBuildingElementProxy>(); bldElProxyIfc2x3.Name = "MyIfcBuildingElementProxy";
var relContainedIn = model.Instances.New<Xbim.Ifc2x3.ProductExtension.IfcRelContainedInSpatialStructure>(); relContainedIn.RelatedElements.Append<Xbim.Ifc2x3.Interfaces.IIfcProduct>(bldElProxyIfc2x3); building.ContainsElements.Append<Xbim.Ifc2x3.Interfaces.IIfcRelContainedInSpatialStructure>(relContainedIn);
But there is still no bldElProxyIfc2x3 in result IFC-file...
relContainedIn.RelatedElements.Add(bldElProxyIfc2x3);
relContainedIn.RelatingStructure = building;