Rework/New: Object & Mesh Select Pies #21

Merged
Demeter Dzadik merged 10 commits from selection_pies into main 2024-09-08 13:06:57 +02:00
Showing only changes of commit 6acd5e9da5 - Show all commits

View File

@ -7,6 +7,7 @@ from bpy.types import Menu, Operator, Constraint, UILayout, Object
from .hotkeys import register_hotkey
from bpy.props import BoolProperty, StringProperty
from bpy.utils import flip_name
from .pie_camera import get_current_camera
class PIE_MT_object_selection(Menu):
@ -17,7 +18,7 @@ class PIE_MT_object_selection(Menu):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
pie.operator("object.select_all", text="Deslect All", icon='OUTLINER_DATA_POINTCLOUD').action='DESELECT'
pie.operator("object.select_all", text="Deselect All", icon='OUTLINER_DATA_POINTCLOUD').action='DESELECT'
# 6 - RIGHT
pie.operator("object.select_all", text="Select All", icon='OUTLINER_OB_POINTCLOUD').action='SELECT'
# 2 - BOTTOM
@ -29,7 +30,7 @@ class PIE_MT_object_selection(Menu):
# 9 - TOP - RIGHT
pie.operator("object.select_siblings_of_active", text="Siblings", icon='PARTICLES')
# 1 - BOTTOM - LEFT
pie.operator("object.select_children_of_active", text=f"All Children", icon='OUTLINER').recursive=True
pie.operator("object.select_active_camera", text=f"Active Camera", icon='OUTLINER_OB_CAMERA')
# 3 - BOTTOM - RIGHT
pie.menu("PIE_MT_object_selection_more", text="Select Menu", icon='THREE_DOTS')
@ -59,9 +60,6 @@ class PIE_MT_object_selection_more(Menu):
layout.operator("object.select_pattern", text="Select Pattern...", icon='FILTER')
layout.operator('object.select_by_name_search', icon='VIEWZOOM')
layout.separator()
layout.operator("object.select_camera", text="Select Active Camera", icon='OUTLINER_OB_CAMERA')
### Object relationship selection operators.
@ -213,6 +211,31 @@ class OBJECT_OT_select_parent_object(Operator, ObjectSelectOperatorMixin):
return {'FINISHED'}
class OBJECT_OT_select_active_camera(Operator, ObjectSelectOperatorMixin):
"""Select the active camera of the scene or viewport"""
bl_idname = "object.select_active_camera"
bl_label = "Select Active Camera"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
cam = get_current_camera(context)
if not cam:
cls.poll_message_set("No active camera.")
return False
return True
def execute(self, context):
super().execute(context)
cam = get_current_camera(context)
if context.mode != 'MODE':
bpy.ops.object.mode_set(mode='OBJECT')
cam.select_set(True)
context.view_layer.objects.active = cam
return {'FINISHED'}
### Object name-based selection operators.
@ -485,7 +508,7 @@ class PIE_MT_mesh_selection(Menu):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
pie.operator("mesh.select_all", text="Deslect All", icon='OUTLINER_DATA_POINTCLOUD').action='DESELECT'
pie.operator("mesh.select_all", text="Deselect All", icon='OUTLINER_DATA_POINTCLOUD').action='DESELECT'
# 6 - RIGHT
pie.operator("mesh.select_all", text="Select All", icon='OUTLINER_OB_POINTCLOUD').action='SELECT'
# 2 - BOTTOM
@ -546,6 +569,8 @@ registry = [
OBJECT_OT_select_siblings_of_active,
OBJECT_OT_select_parent_object,
OBJECT_OT_select_active_camera,
PIE_MT_select_object_name_relation,
OBJECT_OT_select_symmetry_object,
OBJECT_OT_select_object_by_name_search,