简体   繁体   English

使用 Ifc2x3 获取 object 的所有属性

[英]Getting all properties of object using Ifc2x3

I am trying to retrieve all the properties in every item stored in an IFC file, similar to what you see when you select an item in xbim explorer and you get all data such as Type, DefiningType, GlobalID and so on.我正在尝试检索存储在 IFC 文件中的每个项目中的所有属性,类似于您在 xbim 资源管理器中的 select 项目中看到的内容,并且您获得所有数据,例如类型、定义类型、全局 ID 等。

The xbim docs contains a relevant example: 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}");
}

However, the code above does not compile when using the Ifc2x3 kernel.但是,上面的代码在使用 Ifc2x3 kernel 时无法编译。 And my IFC model does not work with Ifc4.而我的 IFC model 不适用于 Ifc4。

What is the Ifc2x3 equivalent of Ifc2x3 等价于什么

    var properties = theDoor.IsDefinedBy
        .Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
        .SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties)
        .OfType<IIfcPropertySingleValue>();

Or even better, how to loop ever every item in the IFC model and retrieve all properies for each one (Ifc2x3)?或者更好的是,如何循环 IFC model 中的每个项目并检索每个项目的所有属性(Ifc2x3)?

What is the Ifc2x3 equivalent Ifc2x3 等价物是什么

You just need to replace: theDoor.IsDefinedBy by theDoor.IsDefinedByProperties您只需将: theDoor.IsDefinedBy 替换为 theDoor.IsDefinedByProperties

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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