From 8b34eb41fdb16a7d8040f1f097eb89822af29042 Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Fri, 8 Oct 2021 13:10:24 +0200 Subject: [PATCH] Fix and test importing style attributes twice (#1784) * Test importing surface attributes twice * Fix style attributes not cleared when re-importing --- src/blenderbim/blenderbim/tool/style.py | 1 + src/blenderbim/test/tool/test_style.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/blenderbim/blenderbim/tool/style.py b/src/blenderbim/blenderbim/tool/style.py index 0ddac3d0a5..43416fe1e9 100644 --- a/src/blenderbim/blenderbim/tool/style.py +++ b/src/blenderbim/blenderbim/tool/style.py @@ -103,6 +103,7 @@ class Style(blenderbim.core.tool.Style): @classmethod def import_surface_attributes(cls, style, obj): + obj.BIMStyleProperties.attributes.clear() blenderbim.bim.helper.import_attributes2(style, obj.BIMStyleProperties.attributes) @classmethod diff --git a/src/blenderbim/test/tool/test_style.py b/src/blenderbim/test/tool/test_style.py index 029892026a..6b2fc509bb 100644 --- a/src/blenderbim/test/tool/test_style.py +++ b/src/blenderbim/test/tool/test_style.py @@ -163,6 +163,19 @@ class TestImportSurfaceAttributes(NewFile): assert obj.BIMStyleProperties.attributes.get("Name").string_value == "Name" assert obj.BIMStyleProperties.attributes.get("Side").enum_value == "BOTH" + def test_importing_surface_attributes_twice(self): + ifc = ifcopenshell.file() + style = ifc.createIfcSurfaceStyle("Name", "BOTH") + obj = bpy.data.materials.new("Material") + subject.import_surface_attributes(style, obj) + assert len(obj.BIMStyleProperties.attributes) == 2 + assert obj.BIMStyleProperties.attributes.get("Name").string_value == "Name" + assert obj.BIMStyleProperties.attributes.get("Side").enum_value == "BOTH" + subject.import_surface_attributes(style, obj) + assert len(obj.BIMStyleProperties.attributes) == 2 + assert obj.BIMStyleProperties.attributes.get("Name").string_value == "Name" + assert obj.BIMStyleProperties.attributes.get("Side").enum_value == "BOTH" + class TestLink(NewFile): def test_run(self):