mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
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:
@@ -1052,16 +1052,29 @@ class OverrideDuplicateMove(bpy.types.Operator):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def execute_ifc_duplicate_operator(operator: bpy.types.Operator, context: bpy.types.Context, linked: bool = False):
|
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:
|
for obj in context.selected_objects:
|
||||||
if element := tool.Ifc.get_entity(obj):
|
element = tool.Ifc.get_entity(obj)
|
||||||
if element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
|
if not element:
|
||||||
tool.Blender.deselect_object(obj)
|
continue
|
||||||
operator.report({"ERROR"}, "Drawing not duplicated.")
|
|
||||||
elif tool.Geometry.is_locked(element):
|
if element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
|
||||||
tool.Blender.deselect_object(obj)
|
objects_to_remove.add(obj)
|
||||||
operator.report({"ERROR"}, lock_error_message(obj.name))
|
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(
|
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:
|
if new_active_obj:
|
||||||
context.view_layer.objects.active = new_active_obj
|
context.view_layer.objects.active = new_active_obj
|
||||||
|
|||||||
@@ -2128,7 +2128,8 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
cls.remove_linked_aggregate_data(old_to_new)
|
cls.remove_linked_aggregate_data(old_to_new)
|
||||||
bonsai.bim.handler.refresh_ui_data()
|
bonsai.bim.handler.refresh_ui_data()
|
||||||
tool.Root.reload_grid_decorator()
|
tool.Root.reload_grid_decorator()
|
||||||
return old_to_new, active_object
|
return old_to_new, new_active_obj or active_object
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def duplicate_ifc_item(cls, obj: bpy.types.Object) -> None:
|
def duplicate_ifc_item(cls, obj: bpy.types.Object) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user