@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.