Fix bug where copy to structure feature was completely inaccessible from the UI

This commit is contained in:
Dion Moult
2025-08-18 17:30:56 +10:00
parent f9dc7d5d94
commit ddbe62772d
2 changed files with 6 additions and 25 deletions
@@ -237,16 +237,14 @@ class CopyToContainer(bpy.types.Operator, tool.Ifc.Operator):
Example: bulk copy a wall to multiple storeys
1. Select one or more 3D elements in the viewport
2. Select one or more spatial containers in the viewport
3. Press this button
4. The copied elements will have a new position relative to the destination containers
The copied elements will have a new position relative to the destination containers
Copying containers to other containers currently is not supported."""
bl_idname = "bim.copy_to_container"
bl_label = "Copy To Container"
bl_options = {"REGISTER", "UNDO"}
container: bpy.props.IntProperty()
def _execute(self, context):
objs = tool.Spatial.get_selected_objects_without_containers()
@@ -254,7 +252,9 @@ class CopyToContainer(bpy.types.Operator, tool.Ifc.Operator):
self.report({"INFO"}, "No non-spatial objects are selected.")
return
containers = tool.Spatial.get_selected_containers()
# TODO: make a multi-select in the spatial decomposition panel to support multiple containers
# containers = tool.Spatial.get_selected_containers()
containers = [tool.Ifc.get().by_id(self.container)]
# Track decompositions so they can be recreated after the operation
relationships = tool.Root.get_decomposition_relationships(objs)
old_to_new = {}
+1 -20
View File
@@ -55,26 +55,6 @@ class BIM_PT_spatial(Panel):
row.prop(osprops, "container_obj", text="", icon="OUTLINER_COLLECTION")
row.operator("bim.assign_container", icon="CHECKMARK", text="")
row.operator("bim.disable_editing_container", icon="CANCEL", text="")
# TODO: deprecate as it's very hard to discover
# containers are not even selectable by default.
if SpatialData.data["selected_containers"]:
row = self.layout.row()
row.label(text=f"{len(SpatialData.data['selected_containers'])} Selected Containers")
for name in SpatialData.data["selected_containers"][:3]:
row = self.layout.row()
row.label(text=name, icon="OUTLINER_COLLECTION")
if len(SpatialData.data["selected_containers"]) > 3:
row = self.layout.row()
row.label(text=f"... {len(SpatialData.data['selected_containers']) - 3} More")
row = self.layout.row(align=True)
row.operator("bim.reference_structure", icon="LINKED", text="Reference Selected")
row.operator("bim.dereference_structure", icon="UNLINKED", text="")
row = self.layout.row()
row.operator("bim.copy_to_container", icon="COPYDOWN", text="Copy Object To Selected")
else:
row = self.layout.row()
row.label(text="No Selected Containers")
else:
row = self.layout.row(align=True)
if SpatialData.data["label"]:
@@ -211,6 +191,7 @@ class BIM_PT_spatial_decomposition(Panel):
row_ = col.row(align=True)
row_.operator("bim.assign_container", icon="FOLDER_REDIRECT", text="").container = ifc_definition_id
row_.operator("bim.reference_from_provided_structure", icon="LINKED", text="").structure = ifc_definition_id
row_.operator("bim.copy_to_container", icon="MOD_DISPLACE", text="").container = ifc_definition_id
col = row.column()
row_ = col.row(align=True)