From 2386ff1abc1f533b88e8886c6b986321a0d561a3 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Mon, 20 Oct 2025 15:44:37 +0200 Subject: [PATCH] BIM: fix multi-material transparency IFC export issue (#24643) * BIM: fix multi-material transparency IFC export issue Fixes #22896. --- src/Mod/BIM/importers/exportIFC.py | 32 +++++++++++------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/Mod/BIM/importers/exportIFC.py b/src/Mod/BIM/importers/exportIFC.py index 89be0fcad2..b50f1db81c 100644 --- a/src/Mod/BIM/importers/exportIFC.py +++ b/src/Mod/BIM/importers/exportIFC.py @@ -2517,29 +2517,21 @@ def getRepresentation( rgbt.append(diffusecolor[0]) i += len(sol.Faces) for i, shape in enumerate(colorshapes): - if i < len(rgbt): - key = rgbt[i] - else: - key = rgbt[0] - # if hasattr(obj,"Material"): - # if obj.Material: - # key = obj.Material.Name #TODO handle multimaterials + # TODO handle multimaterials + if i >= len(rgbt): + i = 0 + key = rgbt[i] + mat = None + if getattr(obj, "Material", None): + mat = obj.Material.Label + if hasattr(obj.Material, "Transparency"): + # Can obj.Material.Transparency (single material) really + # be different from obj.ViewObject.Transparency? + key = key[:3] + (obj.Material.Transparency / 100.0,) if key in surfstyles: psa = surfstyles[key] else: - m = None - if hasattr(obj, "Material"): - if obj.Material: - m = obj.Material.Label - rgbt[i] = ( - rgbt[i][0], - rgbt[i][1], - rgbt[i][2], - obj.Material.Transparency / 100.0, - ) - psa = ifcbin.createIfcPresentationStyleAssignment( - m, rgbt[i][0], rgbt[i][1], rgbt[i][2], rgbt[i][3] - ) + psa = ifcbin.createIfcPresentationStyleAssignment(mat, *key) surfstyles[key] = psa isi = ifcfile.createIfcStyledItem(shape, [psa], None)