[英]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.