0

I'm using XBim IFC libraries in order to get some info of a Building model elements. Specifically, of IfcWall entities.

I have to acces Wall Base Quantities (lenght, height, width, etc.) but I cant reach those properties from IfcWall class.

I have this class:

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();
                }
            }
        }
    }
}

That lambda expression return me a row, correctly filtered by Name parameter, as this property is accessible. But I cant access the property call "LengthValue", the strange thing is that the property is visible during debbugin if I put a breakpoint, under "prop" list in the foreach loop.

Anyone could give me an idea of what could be happening? Thanks in advance!

DarkBee
  • 16,592
  • 6
  • 46
  • 58

1 Answers1

0

This is because LengthValue is a property of IfcQuantityLength, but PhysicalSimpleQuantities are of supertype IfcPhysicalQuantity. You just need to select quantities of the right type

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

Martin Cerny
  • 344
  • 3
  • 9