mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +00:00
improvements on dealing with sub-aggregates
This commit is contained in:
@@ -1155,21 +1155,32 @@ class DuplicateMoveLinkedAggregate(bpy.types.Operator):
|
|||||||
self.report({"INFO"}, "Object is not part of a IfcElementAssembly.")
|
self.report({"INFO"}, "Object is not part of a IfcElementAssembly.")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
select_objects_and_add_data(selected_element)
|
select_objects_and_add_data(selected_element)
|
||||||
|
|
||||||
old_to_new = OverrideDuplicateMove.execute_ifc_duplicate_operator(self, context, linked=True)
|
old_to_new = OverrideDuplicateMove.execute_ifc_duplicate_operator(self, context, linked=True)
|
||||||
|
|
||||||
|
# TODO check how this will interact with the new code from duplicate operator
|
||||||
for old_element, new_element in old_to_new.items():
|
for old_element, new_element in old_to_new.items():
|
||||||
old_parent = ifcopenshell.util.element.get_aggregate(old_element)
|
old_aggregate = ifcopenshell.util.element.get_aggregate(old_element)
|
||||||
if old_parent:
|
if old_aggregate:
|
||||||
new_parent = old_to_new[old_parent]
|
if old_element.GlobalId == selected_element.GlobalId:
|
||||||
blenderbim.core.aggregate.assign_object(
|
blenderbim.core.aggregate.unassign_object(
|
||||||
tool.Ifc,
|
tool.Ifc,
|
||||||
tool.Aggregate,
|
tool.Aggregate,
|
||||||
tool.Collector,
|
tool.Collector,
|
||||||
relating_obj=tool.Ifc.get_object(new_parent[0]),
|
relating_obj=tool.Ifc.get_object(old_aggregate),
|
||||||
related_obj=tool.Ifc.get_object(new_element[0]),
|
related_obj=tool.Ifc.get_object(new_element[0]),
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
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_element[0]),
|
||||||
|
)
|
||||||
|
|
||||||
blenderbim.bim.handler.refresh_ui_data()
|
blenderbim.bim.handler.refresh_ui_data()
|
||||||
|
|
||||||
@@ -1237,6 +1248,8 @@ class RefreshLinkedAggregate(bpy.types.Operator):
|
|||||||
for element in elements:
|
for element in elements:
|
||||||
if element.GlobalId == selected_element.GlobalId:
|
if element.GlobalId == selected_element.GlobalId:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
element_aggregate = ifcopenshell.util.element.get_aggregate(element)
|
||||||
|
|
||||||
selected_matrix = selected_obj.matrix_world
|
selected_matrix = selected_obj.matrix_world
|
||||||
object_duplicate = tool.Ifc.get_object(element)
|
object_duplicate = tool.Ifc.get_object(element)
|
||||||
@@ -1250,19 +1263,32 @@ class RefreshLinkedAggregate(bpy.types.Operator):
|
|||||||
tool.Ifc.get_object(selected_element).select_set(True)
|
tool.Ifc.get_object(selected_element).select_set(True)
|
||||||
|
|
||||||
old_to_new = DuplicateMoveLinkedAggregate.execute_ifc_duplicate_linked_aggregate_operator(self, context)
|
old_to_new = DuplicateMoveLinkedAggregate.execute_ifc_duplicate_linked_aggregate_operator(self, context)
|
||||||
|
|
||||||
for old, new in old_to_new.items():
|
for old, new in old_to_new.items():
|
||||||
# if new[0].is_a("IfcColumn"):
|
|
||||||
new_obj = tool.Ifc.get_object(new[0])
|
new_obj = tool.Ifc.get_object(new[0])
|
||||||
new_base_matrix = Matrix.LocRotScale(*duplicate_matrix)
|
new_base_matrix = Matrix.LocRotScale(*duplicate_matrix)
|
||||||
matrix_diff = Matrix.inverted(selected_matrix) @ new_obj.matrix_world
|
matrix_diff = Matrix.inverted(selected_matrix) @ new_obj.matrix_world
|
||||||
new_obj_matrix = new_base_matrix @ matrix_diff
|
new_obj_matrix = new_base_matrix @ matrix_diff
|
||||||
new_obj.matrix_world = new_obj_matrix
|
new_obj.matrix_world = new_obj_matrix
|
||||||
|
|
||||||
# TODO test with adding subaggregates to existing aggregates
|
|
||||||
|
if element_aggregate and new[0].is_a("IfcElementAssembly"):
|
||||||
# TODO test with ctrl+shift+d in a subaggregates
|
new_aggregate = ifcopenshell.util.element.get_aggregate(new[0])
|
||||||
|
print("E-", element_aggregate)
|
||||||
|
print("A-", new_aggregate)
|
||||||
|
print("N-", new[0])
|
||||||
|
if not new_aggregate:
|
||||||
|
blenderbim.core.aggregate.assign_object(
|
||||||
|
tool.Ifc,
|
||||||
|
tool.Aggregate,
|
||||||
|
tool.Collector,
|
||||||
|
relating_obj=tool.Ifc.get_object(element_aggregate),
|
||||||
|
related_obj=tool.Ifc.get_object(new[0]),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO Add a "Mirror" option that treats the matrix differently
|
||||||
|
|
||||||
# TODO think of more edge cases and issues already reported
|
# TODO think of more edge cases and issues already reported
|
||||||
|
|
||||||
blenderbim.bim.handler.refresh_ui_data()
|
blenderbim.bim.handler.refresh_ui_data()
|
||||||
|
|||||||
Reference in New Issue
Block a user