[英]How to get the material data of specific IfcElement
In the basic operations in the xbim examples https://docs.xbim.net/examples/basic-model-operations.html , it shows how to retrieve the single value properties of a specific IfcElement.在 xbim 示例https://docs.xbim.net/examples/basic-model-operations.html的基本操作中,它显示了如何检索特定 IfcElement 的单值属性。 Based on this I've tried to get the material data.基于此,我试图获取材料数据。
I've written the following:我写了以下内容:
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>();
It gives me this error:它给了我这个错误:
'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?) “IIfcRelAssociates”不包含“RelatingMaterial”的定义,并且找不到接受“IIfcRelAssociates”类型的第一个参数的可访问扩展方法“RelatingMaterial”(您是否缺少 using 指令或程序集引用?)
I understand that I have to use the IfcRelAssociatesMaterial, but I can't figure how.我知道我必须使用 IfcRelAssociatesMaterial,但我不知道如何使用。 How can I retrieve the material information?如何检索材料信息?
IIfcObjectDefinition's HasAssociations
returns a set of IIfcRelAssociates
but you want just the derived type IIfcRelAssociatesMaterial
which has the RelatingMaterial
property. IIfcObjectDefinition 的HasAssociations
返回一组IIfcRelAssociates
,但您只需要具有RelatingMaterial
属性的派生类型IIfcRelAssociatesMaterial
。 See https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2/HTML/schema/ifcproductextension/lexical/ifcrelassociatesmaterial.htm请参阅https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2/HTML/schema/ifcproductextension/lexical/ifcrelassociatesmaterial.htm
So, it's just a matter of adding .OfType<IIfcRelAssociatesMaterial>
to constrain the query to Material associations.因此,只需添加.OfType<IIfcRelAssociatesMaterial>
即可将查询约束到材质关联。 ie IE
var materials = theWall.HasAssociations.OfType<IIfcRelAssociatesMaterial>()
// rest of the query
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.