mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
You can now make a spatial element the active object from the spatial decomposition panel
This commit is contained in:
@@ -146,9 +146,17 @@ class SelectContainer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.select_container"
|
||||
bl_label = "Select Container"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
container: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
core.select_container(tool.Ifc, tool.Spatial, obj=context.active_object)
|
||||
if self.container:
|
||||
container = tool.Ifc.get().by_id(self.container)
|
||||
elif element := tool.Ifc.get_entity(context.active_object):
|
||||
container = ifcopenshell.util.element.get_container(element)
|
||||
else:
|
||||
return
|
||||
if container:
|
||||
core.select_container(tool.Ifc, tool.Spatial, container=container)
|
||||
|
||||
|
||||
class SelectSimilarContainer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
@@ -233,7 +241,7 @@ class SelectDecomposedElements(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@classmethod
|
||||
def description(cls, context, operator):
|
||||
return f"Select all elements contained in {operator.ifc_class}"
|
||||
return f"Select all elements contained in this {operator.ifc_class}"
|
||||
|
||||
def _execute(self, context):
|
||||
core.select_decomposed_elements(tool.Spatial, container=tool.Ifc.get().by_id(self.container))
|
||||
|
||||
@@ -61,7 +61,7 @@ class BIM_PT_spatial(Panel):
|
||||
row = self.layout.row(align=True)
|
||||
if SpatialData.data["label"]:
|
||||
row.label(text=SpatialData.data["label"])
|
||||
row.operator("bim.select_container", icon="OBJECT_DATA", text="")
|
||||
row.operator("bim.select_container", icon="OBJECT_DATA", text="").container = 0
|
||||
row.operator("bim.select_similar_container", icon="RESTRICT_SELECT_OFF", text="")
|
||||
row.operator("bim.enable_editing_container", icon="GREASEPENCIL", text="")
|
||||
if SpatialData.data["is_directly_contained"]:
|
||||
@@ -121,7 +121,7 @@ class BIM_PT_spatial_decomposition(Panel):
|
||||
row.operator("bim.import_spatial_decomposition", icon="FILE_REFRESH", text="")
|
||||
|
||||
if self.props.active_container:
|
||||
ifc_definition_id = self.props.active_container.ifc_definition_id if self.props.active_container else 0
|
||||
ifc_definition_id = self.props.active_container.ifc_definition_id
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(self.props, "subelement_class", text="")
|
||||
op = row.operator("bim.add_part_to_object", icon="ADD", text="")
|
||||
@@ -136,8 +136,10 @@ class BIM_PT_spatial_decomposition(Panel):
|
||||
row.operator("bim.select_decomposed_elements", icon="FULLSCREEN_EXIT", text="Isolate")
|
||||
row.operator("bim.select_decomposed_elements", icon="HIDE_OFF", text="")
|
||||
row.operator("bim.select_decomposed_elements", icon="HIDE_ON", text="")
|
||||
row.operator("bim.select_decomposed_elements", icon="OBJECT_DATA", text="")
|
||||
row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="")
|
||||
row.operator("bim.select_container", icon="OBJECT_DATA", text="").container = ifc_definition_id
|
||||
op = row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="")
|
||||
op.ifc_class = self.props.active_container.ifc_class
|
||||
op.container = ifc_definition_id
|
||||
op = row.operator("bim.delete_container", icon="X", text="")
|
||||
op.container = ifc_definition_id
|
||||
|
||||
|
||||
@@ -109,11 +109,8 @@ def copy_to_container(
|
||||
return result_objs
|
||||
|
||||
|
||||
def select_container(ifc: tool.Ifc, spatial: tool.Spatial, obj: bpy.types.Object) -> None:
|
||||
element = ifc.get_entity(obj)
|
||||
if not element:
|
||||
return
|
||||
spatial.set_active_object(ifc.get_object(spatial.get_container(element)))
|
||||
def select_container(ifc: tool.Ifc, spatial: tool.Spatial, container: ifcopenshell.entity_instance) -> None:
|
||||
spatial.set_active_object(ifc.get_object(container))
|
||||
|
||||
|
||||
def select_similar_container(ifc: tool.Ifc, spatial: tool.Spatial, obj: bpy.types.Object) -> None:
|
||||
|
||||
Reference in New Issue
Block a user