在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’(您缺少使用指令还是程序集引用?)
我知道我必须使用IfcRelAssociatesMaterial,但我不知道如何使用。我怎样才能检索到材料信息?
发布于 2020-06-16 18:08:21
IIfcObjectDefinition的HasAssociations返回一组IIfcRelAssociates,但您只需要具有RelatingMaterial属性的派生类型IIfcRelAssociatesMaterial。请参阅https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2/HTML/schema/ifcproductextension/lexical/ifcrelassociatesmaterial.htm
因此,这只是一个添加.OfType<IIfcRelAssociatesMaterial>来约束查询到物质关联的问题。即
var materials = theWall.HasAssociations.OfType<IIfcRelAssociatesMaterial>()
// rest of the queryhttps://stackoverflow.com/questions/62406787
复制相似问题