BIM: fix multi-material transparency IFC export issue (#24643)

* BIM: fix multi-material transparency IFC export issue

Fixes #22896.
This commit is contained in:
Roy-043
2025-10-20 15:44:37 +02:00
committed by GitHub
parent 98c9bca45a
commit 2386ff1abc

View File

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