From cb7e04f61a5708fab2133dab2b751ab55d0793f1 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 15 Apr 2025 11:20:11 +0500 Subject: [PATCH] assign_class - replace object with empty if no representation was added Same goal as ffffcc576e - prevent user confusion when they reload IFC file and see the representation is gone. --- src/bonsai/bonsai/bim/module/root/operator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/bim/module/root/operator.py b/src/bonsai/bonsai/bim/module/root/operator.py index 0c6dd2b90e..7e9aa0fada 100644 --- a/src/bonsai/bonsai/bim/module/root/operator.py +++ b/src/bonsai/bonsai/bim/module/root/operator.py @@ -302,7 +302,11 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator): context=ifc_context, ifc_representation_class=self.ifc_representation_class, ) - tool.Geometry.reload_representation(obj) + representation = tool.Geometry.get_active_representation(obj) + if representation: + tool.Geometry.reload_representation(obj) + elif obj.data is not None: + new_obj = tool.Geometry.recreate_object_with_data(obj, None) # TODO: reload representation might lead to the object being replaced by object of the other type. # We probably should track it somehow and keep the original selection.