繁体   English   中英

使用 Ifc2x3 获取 object 的所有属性

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

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