Fix #6601 - If you duplicate something it makes the duplicate the active object.

also bulk deselect all objects_to_remove to speed things up a little.
This commit is contained in:
Ryan Schultz
2025-04-27 13:12:07 -05:00
parent c9fbec4d46
commit dd1c529544
2 changed files with 23 additions and 9 deletions
@@ -1052,16 +1052,29 @@ class OverrideDuplicateMove(bpy.types.Operator):
@staticmethod
def execute_ifc_duplicate_operator(operator: bpy.types.Operator, context: bpy.types.Context, linked: bool = False):
objects_to_remove = set()
for obj in context.selected_objects:
if element := tool.Ifc.get_entity(obj):
if element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
tool.Blender.deselect_object(obj)
operator.report({"ERROR"}, "Drawing not duplicated.")
elif tool.Geometry.is_locked(element):
tool.Blender.deselect_object(obj)
operator.report({"ERROR"}, lock_error_message(obj.name))
element = tool.Ifc.get_entity(obj)
if not element:
continue
if element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
objects_to_remove.add(obj)
operator.report({"ERROR"}, f"Drawing '{obj.name}' not duplicated.")
continue
if tool.Geometry.is_locked(element):
objects_to_remove.add(obj)
operator.report({"ERROR"}, lock_error_message(obj.name))
for obj in objects_to_remove:
obj.select_set(False)
old_to_new, new_active_obj = tool.Geometry.duplicate_ifc_objects(
set(context.selected_objects), linked=linked, active_object=context.active_object
set(context.selected_objects) - objects_to_remove,
linked=linked,
active_object=context.active_object,
)
if new_active_obj:
context.view_layer.objects.active = new_active_obj
+2 -1
View File
@@ -2128,7 +2128,8 @@ class Geometry(bonsai.core.tool.Geometry):
cls.remove_linked_aggregate_data(old_to_new)
bonsai.bim.handler.refresh_ui_data()
tool.Root.reload_grid_decorator()
return old_to_new, active_object
return old_to_new, new_active_obj or active_object
@classmethod
def duplicate_ifc_item(cls, obj: bpy.types.Object) -> None: