
类库和API
本文基于C#,学习Xbim类库(XbimEssentials)对Ifc数据的各种操作。
关于Xbim,Github地址,官网案例入口,案例之基础模型操作入口,xBIM Toolkit文档。
浏览Ifc文件的轻量级的免费软件
IFC Viewer之一的BIMvision下载地址
官网一些案例的中文版:xbim基本的模型操作
Ifc格式解析Ifc人工解析(以梁为例)、IFC格式说明
关于墙的拉伸IFC中的拉伸体 (IfcExtrudedAreaSolid)
核心代码为:
var ifcExtrudedAreaSolid = ifcStore.Instances.New关于墙-窗孔洞(); ifcExtrudedAreaSolid.ExtrudedDirection = ifcStore.Instances.New (); ifcExtrudedAreaSolid.ExtrudedDirection.SetXYZ(0, 0, 1);//Z轴正方向拉伸 ifcExtrudedAreaSolid.Depth = new IfcPositiveLengthMeasure(3000);//单位毫米
关于孔洞(比如墙里需要挖个洞,填一个窗、门)的介绍:IfcOpeningElement介绍、IfcRelFillsElement介绍
IfcOpeningElement的基本用法(以窗和墙之间的孔洞为例):
var ifcOpeningElement = ifcStore.Instances.New(); ifcOpeningElement.Representation = window2.Representation; IfcRelVoidsElement rve = ifcStore.Instances.New (); IfcRelFillsElement rfe = ifcStore.Instances.New (); rve.RelatedOpeningElement = ifcOpeningElement; rve.RelatingBuildingElement = wall as IfcElement; rfe.RelatingOpeningElement = ifcOpeningElement; rfe.RelatedBuildingElement = window;
以类图关系说明孔洞的创建方式:
尚未添加孔洞前:
添加孔洞后墙和窗的相互调用关系图(比如根据墙,如何找到墙内的窗;反之亦然):
关于Ifc文件的复制(打开一个ifc,复制里面部分构件,另存为一个新的ifc文件):插入复制功能
不能简单地在用IfcStore.Open()打开一个ifc文件后,读取一个ifc里面的建筑构件(如一个墙),将里面的某些实体,直接添加到另一个新创建的Ifc文件中,会报“跨模型实体分配错误”:Xbim.Common.Exceptions.XbimException:“Cross model entity assignment”。因为一个ifc模型的创建遵循严格的事务要求,需要一步步有序创建构件及其内部的关系和属性,不能直接引用别的ifc文件里的构件。
其他介绍Ifc标准及实例介绍