From 35cfea5bd7746ca1c52b15cfc6551c982fb7690c Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 1 Dec 2023 14:52:46 +0500 Subject: [PATCH] Revert "Minor fix - remove redundant code" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 78285081790c22c3ed455f0fffed7a15a2a1f476. Turned out when I was assuming `bim.add_style` is assigning the style but it wasn't, it was `bim.update_representation` on the file save. So basically during the session style wasn't assigned, therefore I added back explicit style assignment. 😬 --- src/blenderbim/blenderbim/bim/module/drawing/operator.py | 3 +++ src/blenderbim/blenderbim/tool/style.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/drawing/operator.py b/src/blenderbim/blenderbim/bim/module/drawing/operator.py index 83f7e1cfc4..63fd5106e2 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/operator.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/operator.py @@ -2624,6 +2624,9 @@ class AddReferenceImage(bpy.types.Operator, Operator): obj.material_slots[0].material = material bpy.ops.bim.add_style() + style = ifc_file.by_id(material.BIMMaterialProperties.ifc_style_id) + tool.Style.assign_style_to_object(style, obj) + material.diffuse_color = (0.031379, 0, 0.801157, 1) material.BIMStyleProperties.diffuse_path = self.filepath material.BIMStyleProperties.uv_mode = "Generated" diff --git a/src/blenderbim/blenderbim/tool/style.py b/src/blenderbim/blenderbim/tool/style.py index 7448dcd84f..271a521067 100644 --- a/src/blenderbim/blenderbim/tool/style.py +++ b/src/blenderbim/blenderbim/tool/style.py @@ -506,3 +506,9 @@ class Style(blenderbim.core.tool.Style): else: items.append(item) return items + + @classmethod + def assign_style_to_object(cls, style, obj): + """assigns `style` to `object` current representation""" + representation = tool.Geometry.get_active_representation(obj) + tool.Ifc.run("style.assign_representation_styles", shape_representation=representation, styles=[style])