选择"IFC墙的物理简单数量"



我使用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参数正确筛选,因为此属性是可访问的。但我无法访问物业电话";"长度值";,奇怪的是,如果我在";道具";foreach循环中的列表。

有人能告诉我可能发生的事情吗?提前感谢!

这是因为LengthValue是IfcQuantityLength的属性,但PhysicalSimpleQuantities是超类型IfcPhysicalQuantity。您只需要选择正确类型的数量
var height = wall.PhysicalSimpleQuantities
.OfType<IfcQuantityLength>()
.Where(x=>x.Name=="Height")?
.LengthValue;

相关内容

  • 没有找到相关文章

最新更新