mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 01:11:40 +00:00
By default the "Select container" button in the spatial decomposition panel clears current selection before selecting the container. Shift + Click adds the container to selection, ALT + Click removes the container from selection. Added tooltip to the button for keypresses.
This commit is contained in:
@@ -159,7 +159,18 @@ class SelectContainer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.select_container"
|
||||
bl_label = "Select Container"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = "SHIFT + Click to add container to selection\nALT + Click to remove container from selection"
|
||||
container: bpy.props.IntProperty()
|
||||
selection_mode: bpy.props.EnumProperty(items=[["ADD"] * 3, ["REMOVE"] * 3, ["SINGLE" * 3]])
|
||||
|
||||
def invoke(self, context, event):
|
||||
if event.shift:
|
||||
self.selection_mode = "ADD"
|
||||
elif event.alt:
|
||||
self.selection_mode = "REMOVE"
|
||||
else:
|
||||
self.selection_mode = "SINGLE"
|
||||
return self.execute(context)
|
||||
|
||||
def _execute(self, context):
|
||||
if self.container:
|
||||
@@ -169,7 +180,12 @@ class SelectContainer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
else:
|
||||
return
|
||||
if container:
|
||||
core.select_container(tool.Ifc, tool.Spatial, container=container)
|
||||
core.select_container(
|
||||
tool.Ifc,
|
||||
tool.Spatial,
|
||||
container=container,
|
||||
selection_mode=self.selection_mode,
|
||||
)
|
||||
|
||||
|
||||
class SelectSimilarContainer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@@ -101,8 +101,10 @@ def copy_to_container(
|
||||
return result_objs
|
||||
|
||||
|
||||
def select_container(ifc: tool.Ifc, spatial: tool.Spatial, container: ifcopenshell.entity_instance) -> None:
|
||||
spatial.set_active_object(ifc.get_object(container))
|
||||
def select_container(
|
||||
ifc: tool.Ifc, spatial: tool.Spatial, container: ifcopenshell.entity_instance, selection_mode: str = "ADD"
|
||||
) -> None:
|
||||
spatial.set_active_object(ifc.get_object(container), selection_mode=selection_mode)
|
||||
|
||||
|
||||
def select_similar_container(ifc: tool.Ifc, spatial: tool.Spatial, obj: bpy.types.Object) -> None:
|
||||
|
||||
@@ -515,12 +515,22 @@ class Blender(bonsai.core.tool.Blender):
|
||||
active_object.select_set(True)
|
||||
|
||||
@classmethod
|
||||
def select_object(cls, obj: bpy.types.Object):
|
||||
def set_object_selection(cls, obj: bpy.types.Object, state: bool = True):
|
||||
try:
|
||||
obj.select_set(True)
|
||||
obj.select_set(state)
|
||||
except RuntimeError: # Trying to select a hidden object throws an error
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def select_object(cls, obj: bpy.types.Object):
|
||||
cls.set_object_selection(obj, True)
|
||||
|
||||
@classmethod
|
||||
def deselect_object(cls, obj: bpy.types.Object, ensure_active_object: bool = True):
|
||||
cls.set_object_selection(obj, False)
|
||||
if ensure_active_object and bpy.context.view_layer.objects.active == obj and bpy.context.selected_objects:
|
||||
cls.set_active_object(bpy.context.selected_objects[-1])
|
||||
|
||||
@classmethod
|
||||
def set_objects_selection(
|
||||
cls,
|
||||
|
||||
@@ -131,8 +131,13 @@ class Spatial(bonsai.core.tool.Spatial):
|
||||
tool.Blender.select_object(obj)
|
||||
|
||||
@classmethod
|
||||
def set_active_object(cls, obj: bpy.types.Object) -> None:
|
||||
tool.Blender.set_active_object(obj)
|
||||
def set_active_object(cls, obj: bpy.types.Object, selection_mode: str = "ADD") -> None:
|
||||
if selection_mode == "ADD":
|
||||
tool.Blender.set_active_object(obj)
|
||||
elif selection_mode == "REMOVE":
|
||||
tool.Blender.deselect_object(obj)
|
||||
else:
|
||||
tool.Blender.select_and_activate_single_object(bpy.context, obj)
|
||||
|
||||
@classmethod
|
||||
def set_relative_object_matrix(
|
||||
|
||||
Reference in New Issue
Block a user