c# - 如何获取特定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's HasAssociations
returns a set of IIfcRelAssociates
but you want just the derived type IIfcRelAssociatesMaterial
which has the RelatingMaterial
property. See 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. i.e.
var materials = theWall.HasAssociations.OfType<IIfcRelAssociatesMaterial>()
// rest of the query
推荐阅读
- java - 如何从 Android 设备(如 Google Pay 应用)获取用户名和电子邮件地址
- groovy - 常规三元运算符可以执行多个操作吗?
- javascript - 无缝缓冲内存 - 磁盘数据对象事物
- csv - 获取网络部分 csv 文件的响应
- node.js - 处理来自 facebook 的链接/推荐中断(Bot Framework v4)
- python - 将像素值返回为“无”
- c++ - 为什么 std::move 复制右值或 const 左值函数参数的内容?
- c# - 如何在 c# 中使用 RS256 算法使用 x509 证书私钥对字符串进行签名?
- react-native - TextInput 不得允许特殊字符和数字
- react-native - 如何在本机反应中访问导出的枚举?