mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +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)
|
recreate_data_structure(new_root_entity)
|
||||||
|
|
||||||
old_objs = []
|
old_objs = []
|
||||||
new_objs = []
|
|
||||||
for old, new in old_to_new.items():
|
for old, new in old_to_new.items():
|
||||||
old_objs.append(tool.Ifc.get_object(old))
|
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)
|
relationships = tool.Root.get_decomposition_relationships(old_objs)
|
||||||
|
|
||||||
tool.Root.recreate_decompositions(relationships, old_to_new)
|
tool.Root.recreate_decompositions(relationships, old_to_new)
|
||||||
|
|
||||||
new_relationships = tool.Root.get_decomposition_relationships(new_objs)
|
|
||||||
|
|
||||||
blenderbim.bim.handler.purge_module_data()
|
blenderbim.bim.handler.purge_module_data()
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class RefreshAggregate(bpy.types.Operator):
|
class RefreshAggregate(bpy.types.Operator):
|
||||||
bl_idname = "bim.refresh_aggregate"
|
bl_idname = "bim.refresh_aggregate"
|
||||||
@@ -957,12 +954,10 @@ class RefreshAggregate(bpy.types.Operator):
|
|||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
self.new_active_obj = None
|
self.new_active_obj = None
|
||||||
old_to_new = {}
|
old_to_new = {}
|
||||||
|
|
||||||
|
|
||||||
def remove_objects(entity, level = -1, parents = []):
|
def remove_objects(entity, level = -1, parents = []):
|
||||||
level +=1
|
level +=1
|
||||||
if level == 0:
|
if level == 0:
|
||||||
@@ -978,7 +973,6 @@ class RefreshAggregate(bpy.types.Operator):
|
|||||||
if part_obj:
|
if part_obj:
|
||||||
tool.Geometry.delete_ifc_object(part_obj)
|
tool.Geometry.delete_ifc_object(part_obj)
|
||||||
|
|
||||||
|
|
||||||
return parents
|
return parents
|
||||||
|
|
||||||
def duplicate_children(entity):
|
def duplicate_children(entity):
|
||||||
@@ -989,8 +983,6 @@ class RefreshAggregate(bpy.types.Operator):
|
|||||||
|
|
||||||
instance_entity = tool.Ifc.get().by_guid(instance_of)
|
instance_entity = tool.Ifc.get().by_guid(instance_of)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not instance_entity.is_a("IfcElementAssembly"):
|
if not instance_entity.is_a("IfcElementAssembly"):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@@ -1009,8 +1001,6 @@ class RefreshAggregate(bpy.types.Operator):
|
|||||||
related_obj=tool.Ifc.get_object(new_part),
|
related_obj=tool.Ifc.get_object(new_part),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def duplicate_objects(obj, is_root = False):
|
def duplicate_objects(obj, is_root = False):
|
||||||
new_obj = obj.copy()
|
new_obj = obj.copy()
|
||||||
if obj.data:
|
if obj.data:
|
||||||
@@ -1042,7 +1032,6 @@ class RefreshAggregate(bpy.types.Operator):
|
|||||||
|
|
||||||
old_to_new[tool.Ifc.get_entity(obj)] = [new_entity]
|
old_to_new[tool.Ifc.get_entity(obj)] = [new_entity]
|
||||||
|
|
||||||
|
|
||||||
return new_entity
|
return new_entity
|
||||||
|
|
||||||
if len(context.selected_objects) != 1:
|
if len(context.selected_objects) != 1:
|
||||||
@@ -1059,36 +1048,42 @@ class RefreshAggregate(bpy.types.Operator):
|
|||||||
if not pset:
|
if not pset:
|
||||||
return {"FINISHED"}
|
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]
|
pset_data = json.loads(pset["Data"])[0]
|
||||||
instance_of = pset_data["instance_of"][0]
|
instance_of = pset_data["instance_of"][0]
|
||||||
original_root_entity = tool.Ifc.get().by_guid(instance_of)
|
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)
|
original_root_object = tool.Ifc.get_object(original_root_entity)
|
||||||
|
|
||||||
selected_matrix = selected_root_obj.matrix_world
|
selected_matrix = selected_root_obj.matrix_world
|
||||||
original_matrix = original_root_object.matrix_world
|
original_matrix = original_root_object.matrix_world
|
||||||
|
|
||||||
for parent in parents:
|
for parent in parents:
|
||||||
|
|
||||||
duplicate_children(parent)
|
duplicate_children(parent)
|
||||||
|
|
||||||
|
|
||||||
|
old_objs = []
|
||||||
for old, new in old_to_new.items():
|
for old, new in old_to_new.items():
|
||||||
|
old_objs.append(tool.Ifc.get_object(old))
|
||||||
|
|
||||||
new_obj = tool.Ifc.get_object(new[0])
|
new_obj = tool.Ifc.get_object(new[0])
|
||||||
|
|
||||||
|
|
||||||
matrix_diff = new_obj.matrix_world @ original_matrix
|
matrix_diff = new_obj.matrix_world @ original_matrix
|
||||||
new_matrix = selected_matrix @ matrix_diff
|
new_matrix = selected_matrix @ matrix_diff
|
||||||
|
|
||||||
|
|
||||||
new_obj.matrix_world = new_matrix
|
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"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class OverrideJoin(bpy.types.Operator, Operator):
|
class OverrideJoin(bpy.types.Operator, Operator):
|
||||||
bl_idname = "bim.override_object_join"
|
bl_idname = "bim.override_object_join"
|
||||||
|
|||||||
Reference in New Issue
Block a user