mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix #2529. Bulk copying decomposed elements to multiple storeys now maintains decomposition.
This commit is contained in:
@@ -547,7 +547,7 @@ class OverrideDuplicateMove(bpy.types.Operator):
|
||||
# Copy the actual class
|
||||
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
|
||||
if new:
|
||||
old_to_new[tool.Ifc.get_entity(obj)] = new
|
||||
old_to_new[tool.Ifc.get_entity(obj)] = [new]
|
||||
# Recreate decompositions
|
||||
tool.Root.recreate_decompositions(relationships, old_to_new)
|
||||
bpy.ops.transform.translate("INVOKE_DEFAULT")
|
||||
|
||||
@@ -131,9 +131,16 @@ class CopyToContainer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
sprops = context.scene.BIMSpatialProperties
|
||||
# Track decompositions so they can be recreated after the operation
|
||||
relationships = tool.Root.get_decomposition_relationships(context.selected_objects)
|
||||
old_to_new = {}
|
||||
containers = [tool.Ifc.get().by_id(c.ifc_definition_id) for c in sprops.containers if c.is_selected]
|
||||
for obj in context.selected_objects:
|
||||
core.copy_to_container(tool.Ifc, tool.Spatial, obj=obj, containers=containers)
|
||||
result_objs = core.copy_to_container(tool.Ifc, tool.Spatial, obj=obj, containers=containers)
|
||||
if result_objs:
|
||||
old_to_new[tool.Ifc.get_entity(obj)] = result_objs
|
||||
# Recreate decompositions
|
||||
tool.Root.recreate_decompositions(relationships, old_to_new)
|
||||
blenderbim.bim.handler.purge_module_data()
|
||||
|
||||
|
||||
|
||||
@@ -69,13 +69,15 @@ def copy_to_container(ifc, spatial, obj=None, containers=None):
|
||||
matrix = spatial.get_relative_object_matrix(obj, ifc.get_object(from_container))
|
||||
else:
|
||||
matrix = spatial.get_object_matrix(obj)
|
||||
result_objs = []
|
||||
for to_container in containers:
|
||||
to_container_obj = ifc.get_object(to_container)
|
||||
copied_obj = spatial.duplicate_object_and_data(obj)
|
||||
spatial.set_relative_object_matrix(copied_obj, to_container_obj, matrix)
|
||||
spatial.run_root_copy_class(obj=copied_obj)
|
||||
result_objs.append(spatial.run_root_copy_class(obj=copied_obj))
|
||||
spatial.run_spatial_assign_container(structure_obj=to_container_obj, element_obj=copied_obj)
|
||||
spatial.disable_editing(obj)
|
||||
return result_objs
|
||||
|
||||
|
||||
def select_container(ifc, spatial, obj=None):
|
||||
|
||||
@@ -106,14 +106,16 @@ class Root(blenderbim.core.tool.Root):
|
||||
@classmethod
|
||||
def recreate_decompositions(cls, relationships, old_to_new):
|
||||
for subelement, data in relationships.items():
|
||||
subelement = old_to_new.get(subelement)
|
||||
element = old_to_new.get(data["element"])
|
||||
if not subelement or not element:
|
||||
new_subelements = old_to_new.get(subelement)
|
||||
new_elements = old_to_new.get(data["element"])
|
||||
if not new_subelements or not new_elements:
|
||||
continue
|
||||
if data["type"] == "fill":
|
||||
obj1 = tool.Ifc.get_object(element)
|
||||
obj2 = tool.Ifc.get_object(subelement)
|
||||
bpy.ops.bim.add_filled_opening(voided_obj=obj1.name, filling_obj=obj2.name)
|
||||
for i, new_subelement in enumerate(new_subelements):
|
||||
new_element = new_elements[i]
|
||||
if data["type"] == "fill":
|
||||
obj1 = tool.Ifc.get_object(new_element)
|
||||
obj2 = tool.Ifc.get_object(new_subelement)
|
||||
bpy.ops.bim.add_filled_opening(voided_obj=obj1.name, filling_obj=obj2.name)
|
||||
|
||||
@classmethod
|
||||
def run_geometry_add_representation(
|
||||
|
||||
Reference in New Issue
Block a user