From d0177891e4eebd59fedd7ec9362f80b9b0394ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Perdig=C3=A3o?= Date: Fri, 22 Sep 2023 16:37:46 -0300 Subject: [PATCH] remove connections with old objects when duplicating aggregates --- .../bim/module/geometry/operator.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/geometry/operator.py b/src/blenderbim/blenderbim/bim/module/geometry/operator.py index cd0d147e94..0c3304e59e 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/operator.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/operator.py @@ -1109,6 +1109,17 @@ class OverrideDuplicateMoveAggregate(bpy.types.Operator): recreate_data_structure(new_root_entity) + # Remove connections with old objects + for new in old_to_new.values(): + for connection in new[0].ConnectedTo: + entity = connection.RelatedElement + if entity in old_to_new.keys(): + core.remove_connection(tool.Geometry, connection=connection) + for connection in new[0].ConnectedFrom: + entity = connection.RelatingElement + if entity in old_to_new.keys(): + core.remove_connection(tool.Geometry, connection=connection) + old_objs = [] for old, new in old_to_new.items(): old_objs.append(tool.Ifc.get_object(old)) @@ -1255,6 +1266,18 @@ class RefreshAggregate(bpy.types.Operator): for parent in parents: duplicate_children(parent) + + # Remove connections with old objects + for new in old_to_new.values(): + for connection in new[0].ConnectedTo: + entity = connection.RelatedElement + if entity in old_to_new.keys(): + core.remove_connection(tool.Geometry, connection=connection) + for connection in new[0].ConnectedFrom: + entity = connection.RelatingElement + if entity in old_to_new.keys(): + core.remove_connection(tool.Geometry, connection=connection) + old_objs = [] for old, new in old_to_new.items(): old_objs.append(tool.Ifc.get_object(old))