【问题标题】:Select IFC Physical Simple Quantity of Wall选择 IFC 物理简单数量的墙
【发布时间】:2022-10-13 18:31:55
【问题描述】:

我正在使用 XBim IFC 库来获取建筑模型元素的一些信息。 具体来说,IfcWall 实体。

我必须访问墙基数量(长度、高度、宽度等),但我无法从 IfcWall 类中访问这些属性。

我有这堂课:

using Dapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xbim.Ifc;
using Xbim.Ifc4.ActorResource;
using Xbim.Ifc4.DateTimeResource;
using Xbim.Ifc4.ExternalReferenceResource;
using Xbim.Ifc4.PresentationOrganizationResource;
using Xbim.Ifc4.GeometricConstraintResource;
using Xbim.Ifc4.GeometricModelResource;
using Xbim.Ifc4.GeometryResource;
using Xbim.Ifc4.Interfaces;
using Xbim.Ifc4.Kernel;
using Xbim.Ifc4.MaterialResource;
using Xbim.Ifc4.MeasureResource;
using Xbim.Ifc4.ProductExtension;
using Xbim.Ifc4.ProfileResource;
using Xbim.Ifc4.PropertyResource;
using Xbim.Ifc4.QuantityResource;
using Xbim.Ifc4.RepresentationResource;
using Xbim.Ifc4.SharedBldgElements;

namespace ProcesadorPremoldeado.IFC
{
    public class IFCCalculos
    {
        public void CalculoPlacas(string fileName, XbimEditorCredentials editor)
        {
            using (var model = IfcStore.Open(fileName, editor))
            {
                using (var transaction = model.BeginTransaction("Quick start transaction"))
                {
                    //get all Walls in the model

                    var ifcWallsList = model.Instances.OfType<IfcWall>();



                    foreach (var wall in ifcWallsList)
                    {
                        var prop = wall.PhysicalSimpleQuantities.Where(x=>x.Name=="Height");

                    }

                    transaction.Commit();
                }
            }
        }
    }
}

该 lambda 表达式返回我一行,由 Name 参数正确过滤,因为此属性是可访问的。 但是我无法访问属性调用“LengthValue”,奇怪的是,如果我在 foreach 循环的“prop”列表下放置断点,则该属性在 debbugin 期间可见。

任何人都可以让我知道会发生什么? 提前致谢!

【问题讨论】:

    标签: c# ifc xbim


    【解决方案1】:

    这是因为LengthValueIfcQuantityLength 的属性,但PhysicalSimpleQuantities 是超类型IfcPhysicalQuantity。您只需要选择正确类型的数量

    var height = wall.PhysicalSimpleQuantities
        .OfType<IfcQuantityLength>()
        .Where(x=>x.Name=="Height")?
        .LengthValue;
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-30
      • 1970-01-01
      • 1970-01-01
      • 2011-01-06
      • 2020-09-05
      • 1970-01-01
      • 2023-03-05
      相关资源
      最近更新 更多