Search code examples
c#xbim

Get TotalThickness value of IFCWALL element


How can I get the TotalThickness value of IFCWALL element using Xbim.Ifc2x3?

As I can see it is contained in wallElement.Material=>ForLayerSet=>TotalThickness or in wallElement.IsTypedBy=>Material=>TotalThickness but when I try to access it by code it wouldn't recognize TotalThickness property.


Solution

  • Just sum up all the thicknesses of material layers. But don't forget to check that the material is actually a material layer set as it might be other type of material.

    var thickness = 
        (ifcWall.HasAssociations.OfType<IfcRelAssociatesMaterial>()
        .FirstOrDefault()?.RelatingMaterial as IfcMaterialLayerSetUsage)?
        .ForLayerSet?.MaterialLayers.Sum(l => l.LayerThickness);
    

    You obviously need to add more null checking logic and probably inspect other possible types of RelatingMaterial as well.