如何获取特定 IfcElement 的 material 数据
How to get the material data of specific IfcElement
在xbim示例https://docs.xbim.net/examples/basic-model-operations.html的基本操作中,它展示了如何检索特定IfcElement的单值属性。基于此,我尝试获取 material 数据。
我写了以下内容:
var id = "3NBPkknun6EuV9fpeE6rFh";
var theWall = model.Instances.FirstOrDefault<IIfcElement>(d => d.GlobalId == id);
var materials = theWall.HasAssociations
.Where(r => r.RelatingMaterial is IIfcMaterialProfileSet)
.SelectMany(r=> ((IIfcMaterialProfileSet)r.RelatingMaterial).MaterialProfiles)
.OfType<IIfcMaterialProfile>();
它给我这个错误:
'IIfcRelAssociates' does not contain a definition for
'RelatingMaterial' and no accessible extension method
'RelatingMaterial' accepting a first argument of type
'IIfcRelAssociates' could be found (are you missing a using directive
or an assembly reference?)
我知道我必须使用 IfcRelAssociatesMaterial,但我不知道如何使用。
如何检索 material 信息?
IIfcObjectDefinition 的 HasAssociations
returns 一组 IIfcRelAssociates
但您只需要具有 RelatingMaterial
属性 的派生类型 IIfcRelAssociatesMaterial
。参见 https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2/HTML/schema/ifcproductextension/lexical/ifcrelassociatesmaterial.htm
因此,只需添加 .OfType<IIfcRelAssociatesMaterial>
即可将查询限制为 Material 关联。即
var materials = theWall.HasAssociations.OfType<IIfcRelAssociatesMaterial>()
// rest of the query
在xbim示例https://docs.xbim.net/examples/basic-model-operations.html的基本操作中,它展示了如何检索特定IfcElement的单值属性。基于此,我尝试获取 material 数据。
我写了以下内容:
var id = "3NBPkknun6EuV9fpeE6rFh";
var theWall = model.Instances.FirstOrDefault<IIfcElement>(d => d.GlobalId == id);
var materials = theWall.HasAssociations
.Where(r => r.RelatingMaterial is IIfcMaterialProfileSet)
.SelectMany(r=> ((IIfcMaterialProfileSet)r.RelatingMaterial).MaterialProfiles)
.OfType<IIfcMaterialProfile>();
它给我这个错误:
'IIfcRelAssociates' does not contain a definition for 'RelatingMaterial' and no accessible extension method 'RelatingMaterial' accepting a first argument of type 'IIfcRelAssociates' could be found (are you missing a using directive or an assembly reference?)
我知道我必须使用 IfcRelAssociatesMaterial,但我不知道如何使用。 如何检索 material 信息?
IIfcObjectDefinition 的 HasAssociations
returns 一组 IIfcRelAssociates
但您只需要具有 RelatingMaterial
属性 的派生类型 IIfcRelAssociatesMaterial
。参见 https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2/HTML/schema/ifcproductextension/lexical/ifcrelassociatesmaterial.htm
因此,只需添加 .OfType<IIfcRelAssociatesMaterial>
即可将查询限制为 Material 关联。即
var materials = theWall.HasAssociations.OfType<IIfcRelAssociatesMaterial>()
// rest of the query