@Hans_Lammerts, I have recieved your file. Your file is IFC2X3, but this diagram from the IFC4 documentation which describes how materials have colours still largely applies.
Your object, say
IfcReinforcingBar, has an
IfcMaterial assigned to it. An
IfcMaterial is purely a material name. By itself, it doesn’t contain complex information such as how it should look or what colour it should have. The example code below taken from your IFC file shows how a simple material called
S 500 is defined and how it is assigned to an
#162= IFCRELASSOCIATESMATERIAL('3jqclFXRX4suObPM94MO4I',#4,$,$,(#167), #163); #163= IFCMATERIAL('S 500'); #167= IFCREINFORCINGBAR('00kx2obfn9xPPzuYYnZ350',#4,'<Unnamed Element>', $,$,#108,#109,$,$,20.,0.503,$,.NOTDEFINED.,$);
As said, the material alone isn’t enough. You also need to define the “style” of a material. So, if you want to apply a colour to a 3D surface, you should have an
IfcSurfaceStyle defined. The code below, taken from your IFC file, describes a surface style used for rendering or shading purposes (as opposed to other purposes such as illumination simulations) of an RGB of
(1, 1, 0), or Yellow colour.
#142= IFCSURFACESTYLERENDERING(#143,$,$,$,$,$,$,$,.NOTDEFINED.); #143= IFCCOLOURRGB($,1.,1.,0.); #144= IFCSURFACESTYLE($,.BOTH.,(#142));
Again, as shown in the below diagram, defining the surface style is not enough. We now need to link the style to the material … and that surface style has to be assigned within a specific representation context (because IFC supports more than just a 3D representation, it also supports 2D representations, or other scale specific representations, or even diagrammatic representations).
Therefore, from the below diagram, we need definitions of an
IfcMaterialDefinitionRepresentation. However, only the
IfcStyledItem is defined in your file shown in the code snippet below. This suggests that the link between the style and the material is not defined properly in your IFC file.
#146= IFCPRESENTATIONSTYLEASSIGNMENT((#144)); #148= IFCSTYLEDITEM(#140,(#146),$);
That said, there are two different ways to map colours to an IFC file. So far, we have been following the “chain” on the left of the diagram. Your particular file takes a different approach, i.e. the chain on the right:
#148= IFCSTYLEDITEM(#140,(#146),$); #140= IFCMAPPEDITEM(#137,#151); #135= IFCSHAPEREPRESENTATION(#34,'Body','MappedRepresentation',(#140)); #109= IFCPRODUCTDEFINITIONSHAPE($,$,(#135)); #167= IFCREINFORCINGBAR('00kx2obfn9xPPzuYYnZ350',#4,'<Unnamed Element>', $,$,#108,#109,$,$,20.,0.503,$,.NOTDEFINED.,$);
As you can see, Allplan has chosen to assign the surface style to the shape itself (notice how
#167 matches the first code block I posted), rather than to the material. This is not my preference, but it is not incorrect. I also believe it is not your preference, since I see that you have carefully named your materials. It would be more efficient to define a small number of materials, one per size, each with its own style and be done with it.
My initial conclusion, but perhaps others might have an opinion, is that buildingSmart has defined two approaches towards assigning a basic colour, and Allplan took one approach. Other IFC viewers that can open your file might not support that approach, and that might explain why you are running into problems.
I should also note that there are some IFC viewers that simply do not visualise any coloured shading. This is not an error, as the raw data is still there, but it is simply the way they choose to visualise the object. One example of this is XBim. You can still check that the appropriate material data has been assigned, which I believe is the more important piece of data.
I would also highlight that it looks as though there are 428 material definitions and material assignment entities in your IFC file. I highly doubt that you have 428 distinct materials in your file as I see many with identical names. This shows that the Allplan exporter is highly inefficient with regards to materials and results in a bloated IFC file. There are other issues with the quality of your IFC file, such as the
<Unnamed Element> shown above rather than using
$, but if I continued with these descriptions, it would be off-topic. Please raise these issues with Allplan.
I hope this helps, and I hope the explanation was clear.