diff --git a/src/bonsai/bonsai/bim/module/spatial/operator.py b/src/bonsai/bonsai/bim/module/spatial/operator.py index 932b105acf..b00d64f77b 100644 --- a/src/bonsai/bonsai/bim/module/spatial/operator.py +++ b/src/bonsai/bonsai/bim/module/spatial/operator.py @@ -78,14 +78,18 @@ class AssignContainer(bpy.types.Operator, tool.Ifc.Operator): bl_label = "Assign Container" bl_description = "Assign current default container to the selected objects" bl_options = {"REGISTER", "UNDO"} + container: bpy.props.IntProperty(options={"SKIP_SAVE"}) def _execute(self, context): props = context.active_object.BIMObjectSpatialProperties - if (container_obj := props.container_obj) and (container := tool.Ifc.get_entity(container_obj)): - for element_obj in context.selected_objects: - core.assign_container( - tool.Ifc, tool.Collector, tool.Spatial, container=container, element_obj=element_obj - ) + if self.container: + container = tool.Ifc.get().by_id(self.container) + elif (container_obj := props.container_obj) and (container := tool.Ifc.get_entity(container_obj)): + pass + for element_obj in context.selected_objects: + core.assign_container( + tool.Ifc, tool.Collector, tool.Spatial, container=container, element_obj=element_obj + ) class EnableEditingContainer(bpy.types.Operator, tool.Ifc.Operator): diff --git a/src/bonsai/bonsai/bim/module/spatial/ui.py b/src/bonsai/bonsai/bim/module/spatial/ui.py index 164ab89c01..8340eb2bb5 100644 --- a/src/bonsai/bonsai/bim/module/spatial/ui.py +++ b/src/bonsai/bonsai/bim/module/spatial/ui.py @@ -159,16 +159,18 @@ class BIM_PT_spatial_decomposition(Panel): if not self.props.total_elements: row = self.layout.row(align=True) - row.label(text=f"{self.props.active_container.ifc_class} > No Contained Elements", icon="FILE_3D") + row.label(text=f"{self.props.active_container.ifc_class} > No Elements", icon="FILE_3D") row.prop(self.props, "should_include_children", text="", icon="OUTLINER") + row.operator("bim.assign_container", icon="FOLDER_REDIRECT", text="").container = ifc_definition_id return row = self.layout.row(align=True) row.label( - text=f"{self.props.active_container.ifc_class} > {self.props.total_elements} Contained Elements", + text=f"{self.props.active_container.ifc_class} > {self.props.total_elements} Elements", icon="FILE_3D", ) row.prop(self.props, "should_include_children", text="", icon="OUTLINER") + row.operator("bim.assign_container", icon="FOLDER_REDIRECT", text="").container = ifc_definition_id op = row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="") op.container = ifc_definition_id