ifcOpenShell get Wall Layers and Materials

Hello everybody! I have been roaming the virutal walls of the OSAArch community for months now and I must say I am really inspiered by the effort a lot of people are putting into.

I am mostly interested in getting data out of an ifc modell and exporting it into excell for example. I found a lot of great code examples on the internet and managed to compile it into a code that extractes all the parameter data from all the elements, but I realized that the layer and material data is missing.

How can I extract the Layer and Material data ouf of a wall for example?
I used the dir() function on a wall and went through all the methods didnt really manage to get somethign usefull out of it. With the "HasAssociations" methodI manage to get a single Material (IfcRelAssociatesMaterial) but if I look the exact same wall in a Ifc viewer I see that it has more layers and materials.

To summarize if I have a list of walls how do I extract the layer information? Example:

Comments

  • A good way without digging too deep, and to immediately support all the complex material types and their usages, is to use the brand-new, evolving, ifcopenshell.api.

    from ifcopenshell.api.material.data import Data
    f = ifcopenshell.open('yourfile.ifc')
    for wall in f.by_type('IfcWall'):
        Data.load(f, wall.id())
        print(Data.products[wall.id()])
    
  • edited April 2021

    Thanks for you answer Dion, but I tried it and I get the following message:
    "ModuleNotFoundError: No module named 'ifcopenshell.api'"
    I downloaded the last relased version (0.6.0 latest) and I still get this error.
    Is this module allready released? Where can I find it?

  • @Borna_Molnar it's super new. The BlenderBIM Add-on ships with it, but because it is so new and evolving, you should grab it straight from git. Here's the folder you're looking for: https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0/src/ifcopenshell-python/ifcopenshell - see the "api" folder in there.

  • @Moult thank you very much! Do you have any idea when this will be "officialy" released in a package? Unfortunately I am not that versed in programming to know what to do with the link you gave me :D

  • @Borna_Molnar You can try overwriting the ifcopenshell folder from your current python installation with the folder indicated by the link above

    Borna_Molnar
  • @Moult said:
    A good way without digging too deep, and to immediately support all the complex material types and their usages, is to use the brand-new, evolving, ifcopenshell.api.

    from ifcopenshell.api.material.data import Data
    f = ifcopenshell.open('yourfile.ifc')
    for wall in f.by_type('IfcWall'):
        Data.load(f, wall.id())
        print(Data.products[wall.id()])
    

    Hello everybody, hello Dion!
    Same as an author of this topic, I am quite new in Python, and even more new in IfcOpenShell. And despite that I am really interested in extraction of materials and material layers from the IFC file. Considering my case, I have been trying to extract the materials in few different ways, but unluckily I didn't succeeded. I am focusing to extract the material layers and its thickness (thermal properties would be ideal, if its even possible) of external building surfaces. I have a code for extraction of external partitions, also I was trying to use proposed ifcopenshell.api, but I wasn't lucky as well.
    The proposed way to use ifcopenshell.api looks promising, but is there are any documentation or guidelines how to work with it, since my I lack of experience to understand it myself? Or do you guys have any suggestions how to extract mentioned data?
    Below there is the a code that I use for external partitions extraction.
    Any comment or suggestion would be appreciated!

    Have a great upcoming new year!

  • edited January 2022

    @Paulius

    Or do you guys have any suggestions how to extract mentioned data?

    I'm not familiar with the ifcopenshell.api, but this might also be a usable method to parse materials

    import ifcopenshell
    ifc_file = ifcopenshell.open("C:\\Users\\cclaus\\Downloads\\example.ifc")
    products = ifc_file.by_type('IfcProduct')
    
    material_list = []
    
    for product in products:
        if product.HasAssociations:
            for i in product.HasAssociations:
                if i.is_a('IfcRelAssociatesMaterial'):
    
                    if i.RelatingMaterial.is_a('IfcMaterial'):
                        material_list.append(i.RelatingMaterial.Name)
    
                    if i.RelatingMaterial.is_a('IfcMaterialList'):
                        for materials in i.RelatingMaterial.Materials:
                            material_list.append(materials.Name)
    
                    if i.RelatingMaterial.is_a('IfcMaterialLayerSetUsage'):
                        for materials in i.RelatingMaterial.ForLayerSet.MaterialLayers:
                            material_list.append(materials.Material.Name)
    
    print (material_list)
    
    
    PauliusLuis
  • @Coen
    Thank you for the quick reply and help! This one works for the parsing materials to materials list, but I'm still struggling with the assignment of extracted materials to exact building elements (external partitions in my case). I tried to use dictionary for this, but it only gives me the same value for all of the elements. Or there is another approach to assign material layers to related elements?
    Of course it might be a dumb question, but for me its a mystery :D

  • edited January 2022

    @Paulius said:
    @Coen
    Thank you for the quick reply and help! This one works for the parsing materials to materials list, but I'm still struggling with the assignment of extracted materials to exact building elements (external partitions in my case). I tried to use dictionary for this, but it only gives me the same value for all of the elements. Or there is another approach to assign material layers to related elements?
    Of course it might be a dumb question, but for me its a mystery :D

    Well, we're here to solve the mystery :-). I don't understand your question fully, are you trying to assign a material to an element? or trying to extract an material from an ifccmateriallayerset?

    I am focusing to extract the material layers and its thickness (thermal properties would be ideal, if its even possible) of external building surfaces

    Yes, I think that's possible. Do you literally mean the surface, like a plane or the layer of the wall which has the material assigned?

    I modelled two identical example cavity walls using BlenderBIM, with the BlenderBIM add-on it's very easy to define your own IfcMaterialLayer with properties. One "wall" I modelled as three seperate walls, the other wall I assigned an IfcMaterialLayerSet with BlenderBIM and a layer thickness.

    Maybe we can use this small example file so we talk about the same things? :-)

    You can see in the properties it has a thickness, so you want that thickness? You could use the following function for this :

    import ifcopenshell
    ifc_file = ifcopenshell.open("C:\\Users\\cclaus\\Downloads\\example.ifc")
    products = ifc_file.by_type('IfcProduct')
    
    def get_materiallayer_set_usage():
    
    
        for product in products:
            if product.HasAssociations:
                for i in product.HasAssociations:
                    if i.is_a('IfcRelAssociatesMaterial'):
                        for materials in i.RelatingMaterial:
                            if (type(materials)) is tuple:
                                for material in materials:
                                    print (product.Name, material.Material, material.LayerThickness)
    
    
    get_materiallayer_set_usage()
    

    it returns

    layered_wall #4228=IfcMaterial('concrete',$,$) 21.0
    layered_wall #4227=IfcMaterial('insulation',$,$) 210.0
    layered_wall #4223=IfcMaterial('brick',$,$) 110.0
    

    You probably know this already, but it is really helpful to read the buildingsmart documentation, so you know where to find the information you need. :-)

    https://standards.buildingsmart.org/IFC/RELEASE/IFC2x2/FINAL/HTML/ifcmaterialresource/lexical/ifcmateriallist.html

    https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcmaterialresource/lexical/ifcmateriallayer.htm

    Some documentation about the Layer thickness
    https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcmaterialresource/lexical/ifcmateriallayerset.htm

    I've attached the example file to this post.

  • @Coen said:
    Well, we're here to solve the mystery :-). I don't understand your question fully, are you trying to assign a material to an element? or trying to extract an material from an ifccmateriallayerset?

    I really appreciate your support! Maybe I expressed myself wrong, my goal is to extract as much as possible data about external building partitions for some energy calculations. I managed to parse external building elements, their area and volume (but this is a different topic), but I do not find a way to extract material layers and layers thickness of these external elements (walls, roofs, doors, etc.).
    I tried your code and example file, it works great and the result is exactly what I am looking, but it only works with your example file. The file that I am using is created with Revit 2021, and the code is returning me only Roof material, despite that the Wall has layer set as well.

    The result looks:

    I excluded the windows and doors from this step, because it requires IfcMaterialConstituenSet usage for this, if I am not mistaken?

  • @Paulius

    The file that I am using is created with Revit 2021, and the code is returning me only Roof material, despite that the Wall has layer set as well.

    I'm not a Revit expert, but I think Revit didn't make a proper IfcMaterialLayerSet when exporting to IFC. Maybe anyone else on this forum know how to do it?
    What you could do is import the IFC in BlenderBIM and assign the LayerThickness there.

    Could you share the .ifc file with us if that's possble?

  • @Coen
    The point is that these attributes are already assigned, I already checked it. Ant it seems that the structure is similar as created with BlenderBIM..

    Also I'm attaching the file, I created this tiny house for test purposes.

  • @Paulius

    I mean, you can modify the LayerThickness using the BlenderBIM add-on if that's a fitting solution for you.

  • edited January 2022

    Hi @Paulius & @Coen
    I have been following this thread, I'm interested in a work flow (with minimal intervention, none preferably) to extract surface areas (maybe constructed Rvalues) of roof, floor and walls/windows with the latter's orientation to North included from an IFC into a spreadsheet. This would take rediculous time wasting out of some building code and thermal envelope calcs we need to do. Currently people are measuring PDFs and paper plans. That is a waste of human potential :) The constructed Rvalues for these elements could be added at the spreadsheet stage or extracted from IFC where the veracity of the data is good. I am keen to hear your comments
    ps Happy New Year to you all

  • @Nigel , @Paulius not sure if this is relevant, I just stumbled across this thread.. I made a project some time ago, where I extract the material layer names and thicknesses of walls (and other information) and print it to excel divided into spaces. It was tested on the Duplex ifc model, which, I believe was originally created in Revit, so it might work on your new version too. Maybe you can use it for something..
    The code itself is here https://github.com/mdjska/daylight-analysis/blob/main/daylight_analysis_load_IFC_data.py, the rest of the repo concerns some daylight analysis, but that file just makes the .xlsx. You can see the resulting excel file in the 'output' folder of the repo.

    NigelCoenduncanMoult
  • @Coen said:
    @Paulius

    I mean, you can modify the LayerThickness using the BlenderBIM add-on if that's a fitting solution for you.

    I can't find this menu anymore in the latest realease of BlenderBIM, how do I assign an IfcMaterialLayer? Has the option for Layerthickness been removed?

  • https://blenderbim.org/docs-python/ifcopenshell-python/code_examples.html

    Is there maybe an easy way now with ifcopenshell to extract all the ifcmaterial definition from the differend IFC schema versions? Could not find in the code examples.

  • Does anyone have any IFC4 models where IfcConstituentSet is used for materials? Just curious..
    Or is there a way to do this in BlenderBIM?

  • @Coen the demo library that ships with the add-on has a window with constituents.

    You can use ifcopenshell.util.element.get_material https://blenderbim.org/docs-python/autoapi/ifcopenshell/util/element/index.html#ifcopenshell.util.element.get_material

    Coen
  • @Moult
    Thanks! You replied just in time! I was already on my way trying to do this 😛:

        if ifc_product.HasAssociations:
            for i in ifc_product.HasAssociations:
                if i.is_a('IfcRelAssociatesMaterial'):
    
                    if i.RelatingMaterial.is_a('IfcMaterialLayerSetUsage'):
                        for materials in i.RelatingMaterial.ForLayerSet.MaterialLayers:
                            material_list.append(materials.Material.Name)
    
                    if i.RelatingMaterial.is_a('IfcMaterialProfileSetUsage'):
                        for ifc_material_profile in (i.RelatingMaterial.ForProfileSet.MaterialProfiles):
                            material_list.append(ifc_material_profile.Material.Name)
    
  • @Moult said:
    @Coen the demo library that ships with the add-on has a window with constituents.

    You can use ifcopenshell.util.element.get_material https://blenderbim.org/docs-python/autoapi/ifcopenshell/util/element/index.html#ifcopenshell.util.element.get_material

    Could it be possible there's maybe a mistake in the documentation?
    it says:

    element = ifcopenshell.by_type("IfcWall")[0]
    material = ifcopenshell.util.element.material(element)
    

    But shouldn't it be?:

    element = ifcopenshell.by_type("IfcWall")[0]
    material = ifcopenshell.util.element.get_material(element)
    
  • came up wit this eventually, just posting it here in case anyone has any pointers:

    def get_ifc_materials(ifc_product):
    
        material_list = []
    
        #deprecated from IFC2x3
        #IfcMaterialList
    
        #IfcMaterialLayerSet
        #IfcMaterialLayerSetUsage
    
        #new entity from IFC4
        #IfcMaterialConstituentSet
        #IfcMaterialProfileSet
    
        if ifc_product:
            ifc_material = ifcopenshell.util.element.get_material(ifc_product)
            if ifc_material:
    
                if ifc_material.is_a('IfcMaterial'):
                    material_list.append(ifc_material.Name)
    
                if ifc_material.is_a('IfcMaterialList'):
                    for materials in ifc_material.Materials:
                       material_list.append(materials.Name)
    
                if ifc_material.is_a('IfcMaterialConstituentSet'):
                    for material_constituents in ifc_material.MaterialConstituents:
                        material_list.append(material_constituents.Material.Name)
    
                if ifc_material.is_a('IfcMaterialLayerSetUsage'):
                    for material_layer in ifc_material.ForLayerSet.MaterialLayers:
                        material_list.append(material_layer.Material.Name)
    
                if ifc_material.is_a('IfcMaterialProfileSetUsage'):
                    for material_profile in (ifc_material.ForProfileSet.MaterialProfiles):
                        material_list.append(material_profile.Material.Name)
    
        if not material_list:
            material_list.append(None)
    
        return material_list
    
  • @Coen yes indeed the docs has an error, would you like to help fix it and submit a PR? (note for simple fixes like these you can just edit the file in Github in your browser, no need to clone and fork etc on your desktop)

  • @Moult said:
    @Coen yes indeed the docs has an error, would you like to help fix it and submit a PR? (note for simple fixes like these you can just edit the file in Github in your browser, no need to clone and fork etc on your desktop)

    I would like to, but I get completely lost on Github repo of ifcopenshell on where the documentation is stored...

Sign In or Register to comment.