moved 'recreate_assembly' to tool/root.py

This commit is contained in:
Bruno Perdigão
2023-11-07 18:28:43 -03:00
parent 4bf0d9ccff
commit 61bd98e7db
2 changed files with 54 additions and 26 deletions
@@ -810,7 +810,7 @@ class OverrideDuplicateMove(bpy.types.Operator):
# Recreate assembly relationship # Recreate assembly relationship
for old in old_to_new.keys(): for old in old_to_new.keys():
if old.is_a("IfcElementAssembly"): if old.is_a("IfcElementAssembly"):
OverrideDuplicateMove.recreate_assembly(old_to_new) tool.Root.recreate_assembly(old_to_new)
# Remove connections with old objects and recreates paths # Remove connections with old objects and recreates paths
OverrideDuplicateMove.remove_old_connections(old_to_new) OverrideDuplicateMove.remove_old_connections(old_to_new)
@@ -856,32 +856,32 @@ class OverrideDuplicateMove(bpy.types.Operator):
return arrays_to_create, array_children return arrays_to_create, array_children
@staticmethod # @staticmethod
def recreate_assembly(old_to_new): # def recreate_assembly(old_to_new):
for old, new in old_to_new.items(): # for old, new in old_to_new.items():
old_aggregate = ifcopenshell.util.element.get_aggregate(old) # old_aggregate = ifcopenshell.util.element.get_aggregate(old)
if old_aggregate: # if old_aggregate:
new_aggregate = old_to_new[old_aggregate] # new_aggregate = old_to_new[old_aggregate]
blenderbim.core.aggregate.assign_object( # blenderbim.core.aggregate.assign_object(
tool.Ifc, # tool.Ifc,
tool.Aggregate, # tool.Aggregate,
tool.Collector, # tool.Collector,
relating_obj=tool.Ifc.get_object(new_aggregate[0]), # relating_obj=tool.Ifc.get_object(new_aggregate[0]),
related_obj=tool.Ifc.get_object(new[0]), # related_obj=tool.Ifc.get_object(new[0]),
) # )
# Make sure that the array children also get reassigned to the correct aggregate # # Make sure that the array children also get reassigned to the correct aggregate
pset = ifcopenshell.util.element.get_pset(new[0], "BBIM_Array") # pset = ifcopenshell.util.element.get_pset(new[0], "BBIM_Array")
if pset: # if pset:
array_children = tool.Blender.Modifier.Array.get_all_children_objects(new[0]) # array_children = tool.Blender.Modifier.Array.get_all_children_objects(new[0])
for obj in array_children: # for obj in array_children:
blenderbim.core.aggregate.assign_object( # blenderbim.core.aggregate.assign_object(
tool.Ifc, # tool.Ifc,
tool.Aggregate, # tool.Aggregate,
tool.Collector, # tool.Collector,
relating_obj=tool.Ifc.get_object(new_aggregate[0]), # relating_obj=tool.Ifc.get_object(new_aggregate[0]),
related_obj=tool.Ifc.get_object(tool.Ifc.get_entity(obj)), # related_obj=tool.Ifc.get_object(tool.Ifc.get_entity(obj)),
) # )
def remove_old_connections(old_to_new): def remove_old_connections(old_to_new):
for new in old_to_new.values(): for new in old_to_new.values():
+28
View File
@@ -230,6 +230,34 @@ class Root(blenderbim.core.tool.Root):
relating_connection=data["relating_connection_type"], relating_connection=data["relating_connection_type"],
related_connection=data["related_connection_type"], related_connection=data["related_connection_type"],
) )
@classmethod
def recreate_assembly(cls, old_to_new):
for old, new in old_to_new.items():
old_aggregate = ifcopenshell.util.element.get_aggregate(old)
if old_aggregate:
new_aggregate = old_to_new[old_aggregate]
blenderbim.core.aggregate.assign_object(
tool.Ifc,
tool.Aggregate,
tool.Collector,
relating_obj=tool.Ifc.get_object(new_aggregate[0]),
related_obj=tool.Ifc.get_object(new[0]),
)
# Make sure that the array children also get reassigned to the correct aggregate
pset = ifcopenshell.util.element.get_pset(new[0], "BBIM_Array")
if pset:
array_children = tool.Blender.Modifier.Array.get_all_children_objects(new[0])
for obj in array_children:
blenderbim.core.aggregate.assign_object(
tool.Ifc,
tool.Aggregate,
tool.Collector,
relating_obj=tool.Ifc.get_object(new_aggregate[0]),
related_obj=tool.Ifc.get_object(tool.Ifc.get_entity(obj)),
)
@classmethod @classmethod