From f7734809178f1790a86a41048ea2b358bc7359cf Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 7 Dec 2023 15:47:48 +0500 Subject: [PATCH] style.edit_surface_style - fix crash setting attribute to None Occured on setting IfcColourOrFactor attribute to None (e.g. DiffuseColour). --- .../ifcopenshell/api/style/edit_surface_style.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py index f0c2447d16..f2ce64495f 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py +++ b/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py @@ -112,11 +112,13 @@ class Usecase: attribute[1] = value["Red"] attribute[2] = value["Green"] attribute[3] = value["Blue"] - else: + else: # assume it's float value for IfcNormalisedRatioMeasure or None existing_value = getattr(self.settings["style"], name) if existing_value and existing_value.id(): self.file.remove(existing_value) - setattr(self.settings["style"], name, self.file.createIfcNormalisedRatioMeasure(value)) + if value is not None: + value = self.file.createIfcNormalisedRatioMeasure(value) + setattr(self.settings["style"], name, value) def edit_specular_highlight(self, value): if value is None: