xbim

Find Material of IPersistentEntity


I have list of IPersistEntity instances, that can be meshed, it means each of them implements one of these interfaces: IIfcFaceBasedSurfaceModel, IIfcShellBasedSurfaceModel, IIfcConnectedFaceSet, IIfcTriangulatedFaceSet, IIfcFacetedBrep.

And I want to find for each of this instance corresponding IIfcMaterial or IIfcSurfaceStyle.

I spend good amount of time digging in the repository but didn't find the way to do this. Will appreciate any help.


Solution

  • You can try to convert your entities to IfcObjectDefinition, you'll be able to get the material from there.

        foreach (var entity in entities)
        {
          var definition = entity as IfcObjectDefinition;
          var material = definition.Material as IIfcMaterial;
        }