mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
recreate decompositions in Refresh operator
This commit is contained in:
committed by
Dion Moult
parent
486bafc814
commit
f96f663dc3
@@ -924,20 +924,17 @@ class OverrideDuplicateMoveAggregate(bpy.types.Operator):
|
||||
recreate_data_structure(new_root_entity)
|
||||
|
||||
old_objs = []
|
||||
new_objs = []
|
||||
for old, new in old_to_new.items():
|
||||
old_objs.append(tool.Ifc.get_object(old))
|
||||
new_objs.append(tool.Ifc.get_object(new[0]))
|
||||
|
||||
relationships = tool.Root.get_decomposition_relationships(old_objs)
|
||||
|
||||
tool.Root.recreate_decompositions(relationships, old_to_new)
|
||||
|
||||
new_relationships = tool.Root.get_decomposition_relationships(new_objs)
|
||||
|
||||
blenderbim.bim.handler.purge_module_data()
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RefreshAggregate(bpy.types.Operator):
|
||||
bl_idname = "bim.refresh_aggregate"
|
||||
@@ -957,12 +954,10 @@ class RefreshAggregate(bpy.types.Operator):
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def _execute(self, context):
|
||||
self.new_active_obj = None
|
||||
old_to_new = {}
|
||||
|
||||
|
||||
def remove_objects(entity, level = -1, parents = []):
|
||||
level +=1
|
||||
if level == 0:
|
||||
@@ -978,7 +973,6 @@ class RefreshAggregate(bpy.types.Operator):
|
||||
if part_obj:
|
||||
tool.Geometry.delete_ifc_object(part_obj)
|
||||
|
||||
|
||||
return parents
|
||||
|
||||
def duplicate_children(entity):
|
||||
@@ -989,8 +983,6 @@ class RefreshAggregate(bpy.types.Operator):
|
||||
|
||||
instance_entity = tool.Ifc.get().by_guid(instance_of)
|
||||
|
||||
|
||||
|
||||
if not instance_entity.is_a("IfcElementAssembly"):
|
||||
return
|
||||
else:
|
||||
@@ -1009,8 +1001,6 @@ class RefreshAggregate(bpy.types.Operator):
|
||||
related_obj=tool.Ifc.get_object(new_part),
|
||||
)
|
||||
|
||||
|
||||
|
||||
def duplicate_objects(obj, is_root = False):
|
||||
new_obj = obj.copy()
|
||||
if obj.data:
|
||||
@@ -1042,7 +1032,6 @@ class RefreshAggregate(bpy.types.Operator):
|
||||
|
||||
old_to_new[tool.Ifc.get_entity(obj)] = [new_entity]
|
||||
|
||||
|
||||
return new_entity
|
||||
|
||||
if len(context.selected_objects) != 1:
|
||||
@@ -1059,36 +1048,42 @@ class RefreshAggregate(bpy.types.Operator):
|
||||
if not pset:
|
||||
return {"FINISHED"}
|
||||
|
||||
parents = remove_objects(selected_root_entity)
|
||||
|
||||
|
||||
pset = ifcopenshell.util.element.get_pset(selected_root_entity, "BBIM_Aggregate_Data")
|
||||
pset_data = json.loads(pset["Data"])[0]
|
||||
instance_of = pset_data["instance_of"][0]
|
||||
original_root_entity = tool.Ifc.get().by_guid(instance_of)
|
||||
if original_root_entity == selected_root_entity:
|
||||
return {"FINISHED"}
|
||||
|
||||
parents = remove_objects(selected_root_entity)
|
||||
|
||||
original_root_object = tool.Ifc.get_object(original_root_entity)
|
||||
|
||||
selected_matrix = selected_root_obj.matrix_world
|
||||
original_matrix = original_root_object.matrix_world
|
||||
|
||||
for parent in parents:
|
||||
|
||||
duplicate_children(parent)
|
||||
|
||||
|
||||
old_objs = []
|
||||
for old, new in old_to_new.items():
|
||||
|
||||
old_objs.append(tool.Ifc.get_object(old))
|
||||
|
||||
new_obj = tool.Ifc.get_object(new[0])
|
||||
|
||||
|
||||
matrix_diff = new_obj.matrix_world @ original_matrix
|
||||
new_matrix = selected_matrix @ matrix_diff
|
||||
|
||||
|
||||
new_obj.matrix_world = new_matrix
|
||||
|
||||
relationships = tool.Root.get_decomposition_relationships(old_objs)
|
||||
|
||||
tool.Root.recreate_decompositions(relationships, old_to_new)
|
||||
|
||||
blenderbim.bim.handler.purge_module_data()
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class OverrideJoin(bpy.types.Operator, Operator):
|
||||
bl_idname = "bim.override_object_join"
|
||||
|
||||
Reference in New Issue
Block a user