From 2d3adce59e8ff2168afe3821253383a889083c98 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 25 Aug 2024 10:51:10 +0200 Subject: [PATCH] Compatibility fix for v0.8 wrapper instances --- src/ifcopenshell-python/ifcopenshell/draw.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/draw.py b/src/ifcopenshell-python/ifcopenshell/draw.py index 47ae335d44..1d25cfd192 100644 --- a/src/ifcopenshell-python/ifcopenshell/draw.py +++ b/src/ifcopenshell-python/ifcopenshell/draw.py @@ -338,7 +338,13 @@ def main( # - style transparency # the factor determines how much white will be interpolated # into the style diffuse color. - clr = numpy.array(style.diffuse if style else (0.6, 0.6, 0.6)) + def clr(c): + if isinstance(c, ifcopenshell.ifcopenshell_wrapper.colour): + return c.r(), c.g(), c.b() + else: + return c + + clr = numpy.array(clr(style.diffuse) if style else (0.6, 0.6, 0.6)) factor = (math.log(elements[0].distance + 2.0) / 7.0) * (1.0 - 0.5 * abs(elements[0].dot_product)) if style and style.has_transparency: factor *= 1.0 - style.transparency