繁体   English   中英

如何获取特定IfcElement的材质数据

[英]How to get the material data of specific IfcElement

在 xbim 示例https://docs.xbim.net/examples/basic-model-operations.html的基本操作中,它显示了如何检索特定 IfcElement 的单值属性。 基于此,我试图获取材料数据。

我写了以下内容:

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”不包含“RelatingMaterial”的定义,并且找不到接受“IIfcRelAssociates”类型的第一个参数的可访问扩展方法“RelatingMaterial”(您是否缺少 using 指令或程序集引用?)

我知道我必须使用 IfcRelAssociatesMaterial,但我不知道如何使用。 如何检索材料信息?

IIfcObjectDefinition 的HasAssociations返回一组IIfcRelAssociates ,但您只需要具有RelatingMaterial属性的派生类型IIfcRelAssociatesMaterial 请参阅https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2/HTML/schema/ifcproductextension/lexical/ifcrelassociatesmaterial.htm

因此,只需添加.OfType<IIfcRelAssociatesMaterial>即可将查询约束到材质关联。 IE

var materials = theWall.HasAssociations.OfType<IIfcRelAssociatesMaterial>() 
// rest of the query

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM