From ffffcc576e3670571fc3704ce5eb4af911ed22c8 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 10 Apr 2025 19:11:21 +0500 Subject: [PATCH] assign_class - reload representation after assignment Just to make sure user will set what was actually saved to IFC right away. To prevent confusion when they see it only after model was reloaded completely. --- src/bonsai/bonsai/bim/module/root/operator.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bonsai/bonsai/bim/module/root/operator.py b/src/bonsai/bonsai/bim/module/root/operator.py index 3e78a2dcbb..0c6dd2b90e 100644 --- a/src/bonsai/bonsai/bim/module/root/operator.py +++ b/src/bonsai/bonsai/bim/module/root/operator.py @@ -290,6 +290,7 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator): should_sync_changes_first=False, ) else: + # TODO: replace empty geometry meshes with empties. element = core.assign_class( tool.Ifc, tool.Collector, @@ -301,6 +302,17 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator): context=ifc_context, ifc_representation_class=self.ifc_representation_class, ) + tool.Geometry.reload_representation(obj) + + # 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. + + # Validation selection. + new_selected_objects = list(filter(tool.Blender.is_valid_data_block, current_selection[2])) + active_object = current_selection[1] + if active_object and not tool.Blender.is_valid_data_block(active_object): + active_object = None + current_selection = (current_selection[0], active_object, new_selected_objects) tool.Blender.set_objects_selection(*current_selection)