[英]Getting all properties of object using Ifc2x3
我正在嘗試檢索存儲在 IFC 文件中的每個項目中的所有屬性,類似於您在 xbim 資源管理器中的 select 項目中看到的內容,並且您獲得所有數據,例如類型、定義類型、全局 ID 等。
xbim 文檔包含一個相關示例:
using System;
using System.Linq;
using Xbim.Ifc;
using Xbim.Ifc4.Interfaces;
const string fileName = "SampleHouse.ifc";
using (var model = IfcStore.Open(fileName))
{
//get one single door
var id = "2AswZfru1AdAiKfEdrNPnu";
var theDoor = model.Instances.FirstOrDefault<IIfcDoor>(d => d.GlobalId == id);
Console.WriteLine($"Door ID: {theDoor.GlobalId}, Name: {theDoor.Name}");
//get all single-value properties of the door
var properties = theDoor.IsDefinedBy
.Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
.SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties)
.OfType<IIfcPropertySingleValue>();
foreach (var property in properties)
Console.WriteLine($"Property: {property.Name}, Value: {property.NominalValue}");
}
但是,上面的代碼在使用 Ifc2x3 kernel 時無法編譯。 而我的 IFC model 不適用於 Ifc4。
Ifc2x3 等價於什么
var properties = theDoor.IsDefinedBy
.Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
.SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties)
.OfType<IIfcPropertySingleValue>();
或者更好的是,如何循環 IFC model 中的每個項目並檢索每個項目的所有屬性(Ifc2x3)?
Ifc2x3 等價物是什么
您只需將: theDoor.IsDefinedBy 替換為 theDoor.IsDefinedByProperties
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.