Revert "Minor fix - remove redundant code"

This reverts commit 7828508179.

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. 😬
This commit is contained in:
Andrej730
2023-12-01 14:52:46 +05:00
parent 661d6bcfe7
commit 35cfea5bd7
2 changed files with 9 additions and 0 deletions
@@ -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"
+6
View File
@@ -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])