mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +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
|
# Copy the actual class
|
||||||
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
|
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
|
||||||
if new:
|
if new:
|
||||||
old_to_new[tool.Ifc.get_entity(obj)] = new
|
old_to_new[tool.Ifc.get_entity(obj)] = [new]
|
||||||
# Recreate decompositions
|
# Recreate decompositions
|
||||||
tool.Root.recreate_decompositions(relationships, old_to_new)
|
tool.Root.recreate_decompositions(relationships, old_to_new)
|
||||||
bpy.ops.transform.translate("INVOKE_DEFAULT")
|
bpy.ops.transform.translate("INVOKE_DEFAULT")
|
||||||
|
|||||||
@@ -131,9 +131,16 @@ class CopyToContainer(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
sprops = context.scene.BIMSpatialProperties
|
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]
|
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:
|
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()
|
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))
|
matrix = spatial.get_relative_object_matrix(obj, ifc.get_object(from_container))
|
||||||
else:
|
else:
|
||||||
matrix = spatial.get_object_matrix(obj)
|
matrix = spatial.get_object_matrix(obj)
|
||||||
|
result_objs = []
|
||||||
for to_container in containers:
|
for to_container in containers:
|
||||||
to_container_obj = ifc.get_object(to_container)
|
to_container_obj = ifc.get_object(to_container)
|
||||||
copied_obj = spatial.duplicate_object_and_data(obj)
|
copied_obj = spatial.duplicate_object_and_data(obj)
|
||||||
spatial.set_relative_object_matrix(copied_obj, to_container_obj, matrix)
|
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.run_spatial_assign_container(structure_obj=to_container_obj, element_obj=copied_obj)
|
||||||
spatial.disable_editing(obj)
|
spatial.disable_editing(obj)
|
||||||
|
return result_objs
|
||||||
|
|
||||||
|
|
||||||
def select_container(ifc, spatial, obj=None):
|
def select_container(ifc, spatial, obj=None):
|
||||||
|
|||||||
@@ -106,14 +106,16 @@ class Root(blenderbim.core.tool.Root):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def recreate_decompositions(cls, relationships, old_to_new):
|
def recreate_decompositions(cls, relationships, old_to_new):
|
||||||
for subelement, data in relationships.items():
|
for subelement, data in relationships.items():
|
||||||
subelement = old_to_new.get(subelement)
|
new_subelements = old_to_new.get(subelement)
|
||||||
element = old_to_new.get(data["element"])
|
new_elements = old_to_new.get(data["element"])
|
||||||
if not subelement or not element:
|
if not new_subelements or not new_elements:
|
||||||
continue
|
continue
|
||||||
if data["type"] == "fill":
|
for i, new_subelement in enumerate(new_subelements):
|
||||||
obj1 = tool.Ifc.get_object(element)
|
new_element = new_elements[i]
|
||||||
obj2 = tool.Ifc.get_object(subelement)
|
if data["type"] == "fill":
|
||||||
bpy.ops.bim.add_filled_opening(voided_obj=obj1.name, filling_obj=obj2.name)
|
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
|
@classmethod
|
||||||
def run_geometry_add_representation(
|
def run_geometry_add_representation(
|
||||||
|
|||||||
Reference in New Issue
Block a user