mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
wip: DuplicateMoveAggregate now calls DuplicateMove function and removes code duplication
This commit is contained in:
@@ -822,6 +822,7 @@ class OverrideDuplicateMove(bpy.types.Operator):
|
|||||||
# Recreate decompositions
|
# Recreate decompositions
|
||||||
tool.Root.recreate_decompositions(relationships, old_to_new)
|
tool.Root.recreate_decompositions(relationships, old_to_new)
|
||||||
blenderbim.bim.handler.refresh_ui_data()
|
blenderbim.bim.handler.refresh_ui_data()
|
||||||
|
return old_to_new
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def process_arrays(self, context):
|
def process_arrays(self, context):
|
||||||
@@ -907,6 +908,8 @@ class OverrideDuplicateMoveAggregate(bpy.types.Operator):
|
|||||||
|
|
||||||
### Adding the assembly data
|
### Adding the assembly data
|
||||||
def add_assembly_data(element, parent, data_to_add):
|
def add_assembly_data(element, parent, data_to_add):
|
||||||
|
obj = tool.Ifc.get_object(element)
|
||||||
|
obj.select_set(True)
|
||||||
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Aggregate_Data")
|
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Aggregate_Data")
|
||||||
data = [data_to_add]
|
data = [data_to_add]
|
||||||
|
|
||||||
@@ -956,12 +959,10 @@ class OverrideDuplicateMoveAggregate(bpy.types.Operator):
|
|||||||
level += 1
|
level += 1
|
||||||
|
|
||||||
data_children = {
|
data_children = {
|
||||||
"children": [],
|
|
||||||
"instance_of": [],
|
"instance_of": [],
|
||||||
}
|
}
|
||||||
|
|
||||||
data_parent = {
|
data_parent = {
|
||||||
"children": [],
|
|
||||||
"instance_of": [entity.GlobalId],
|
"instance_of": [entity.GlobalId],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,11 +977,9 @@ class OverrideDuplicateMoveAggregate(bpy.types.Operator):
|
|||||||
for part in parts:
|
for part in parts:
|
||||||
if part.is_a("IfcElementAssembly"):
|
if part.is_a("IfcElementAssembly"):
|
||||||
add_assembly_data(part, entity, data_children)
|
add_assembly_data(part, entity, data_children)
|
||||||
add_child_to_assembly_data(part)
|
|
||||||
create_data_structure(part, level)
|
create_data_structure(part, level)
|
||||||
continue
|
continue
|
||||||
add_assembly_data(part, entity, data_children)
|
add_assembly_data(part, entity, data_children)
|
||||||
add_child_to_assembly_data(part)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1115,41 +1114,37 @@ class OverrideDuplicateMoveAggregate(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
selected_obj = context.selected_objects[0]
|
selected_obj = context.selected_objects[0]
|
||||||
selected_root_entity = tool.Ifc.get_entity(selected_obj)
|
selected_element = tool.Ifc.get_entity(selected_obj)
|
||||||
|
|
||||||
if not selected_root_entity.is_a("IfcElementAssembly"):
|
if selected_element.is_a("IfcElementAssembly"):
|
||||||
|
pass
|
||||||
|
elif selected_element.Decomposes:
|
||||||
|
if selected_element.Decomposes[0].RelatingObject.is_a("IfcElementAssembly"):
|
||||||
|
selected_element = selected_element.Decomposes[0].RelatingObject
|
||||||
|
selected_obj = tool.Ifc.get_object(selected_element)
|
||||||
|
else:
|
||||||
|
self.report({"INFO"}, "Object is not part of a IfcElementAssembly.")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
pset = ifcopenshell.util.element.get_pset(selected_root_entity, "BBIM_Aggregate_Data")
|
pset = ifcopenshell.util.element.get_pset(selected_element, "BBIM_Aggregate_Data")
|
||||||
if not pset:
|
if not pset:
|
||||||
create_data_structure(selected_root_entity)
|
create_data_structure(selected_element)
|
||||||
|
|
||||||
pset = ifcopenshell.util.element.get_pset(selected_root_entity, "BBIM_Aggregate_Data")
|
old_to_new = OverrideDuplicateMove.execute_ifc_duplicate_operator(self, context, linked=True)
|
||||||
|
|
||||||
selected_root_parent = selected_root_entity
|
for old_element, new_element in old_to_new.items():
|
||||||
|
print(old_element, new_element)
|
||||||
new_root_entity = duplicate_all(selected_obj)
|
old_parent = ifcopenshell.util.element.get_aggregate(old_element)
|
||||||
|
if old_parent:
|
||||||
recreate_data_structure(new_root_entity)
|
new_parent = old_to_new[old_parent]
|
||||||
|
print(new_parent)
|
||||||
# Remove connections with old objects
|
blenderbim.core.aggregate.assign_object(
|
||||||
for new in old_to_new.values():
|
tool.Ifc,
|
||||||
for connection in new[0].ConnectedTo:
|
tool.Aggregate,
|
||||||
entity = connection.RelatedElement
|
tool.Collector,
|
||||||
if entity in old_to_new.keys():
|
relating_obj=tool.Ifc.get_object(new_parent[0]),
|
||||||
core.remove_connection(tool.Geometry, connection=connection)
|
related_obj=tool.Ifc.get_object(new_element[0]),
|
||||||
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))
|
|
||||||
|
|
||||||
relationships = tool.Root.get_decomposition_relationships(old_objs)
|
|
||||||
|
|
||||||
tool.Root.recreate_decompositions(relationships, old_to_new)
|
|
||||||
|
|
||||||
blenderbim.bim.handler.refresh_ui_data()
|
blenderbim.bim.handler.refresh_ui_data()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user