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 d25debc0b0 - Show all commits

View File

@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
import bpy
from bpy.types import Menu
from .hotkeys import register_hotkey
@ -14,25 +15,21 @@ class PIE_MT_object_selection(Menu):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
pie.operator("object.select_grouped", text="Select Grouped")
pie.operator("object.select_all", text="Deslect All", icon='OUTLINER_DATA_POINTCLOUD').action='DESELECT'
# 6 - RIGHT
pie.operator("object.select_by_type", text="Select By Type")
pie.operator("object.select_all", text="Select All", icon='OUTLINER_OB_POINTCLOUD').action='SELECT'
# 2 - BOTTOM
pie.operator(
"object.select_all", text="Invert Selection", icon='ZOOM_PREVIOUS'
).action = 'INVERT'
pie.operator("object.select_grouped", text="Direct Children", icon='CON_CHILDOF').type='CHILDREN'
# 8 - TOP
pie.operator(
"object.select_all", text="Select All Toggle", icon='NONE'
).action = 'TOGGLE'
pie.operator("object.select_grouped", text="Parent", icon='FILE_PARENT').type='PARENT'
# 7 - TOP - LEFT
pie.operator("view3d.select_circle", text="Circle Select")
pie.operator("object.select_grouped", text="Siblings", icon='PARTICLES').type='SIBLINGS'
# 9 - TOP - RIGHT
pie.operator("view3d.select_box", text="Box Select")
pie.operator("object.select_all", text="Invert Selection", icon='CLIPUV_DEHLT').action='INVERT'
# 1 - BOTTOM - LEFT
pie.operator("object.select_camera", text="Select Camera")
pie.operator("object.select_grouped", text="All Children", icon='OUTLINER').type='CHILDREN_RECURSIVE'
# 3 - BOTTOM - RIGHT
pie.menu("PIE_MT_object_selection_more", text="Select Menu")
pie.menu("PIE_MT_object_selection_more", text="Select Menu", icon='THREE_DOTS')
class PIE_MT_mesh_selection(Menu):
@ -43,21 +40,21 @@ class PIE_MT_mesh_selection(Menu):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
pie.operator("mesh.select_less", text="Select Less")
pie.operator("mesh.select_all", text="Deslect All", icon='OUTLINER_DATA_POINTCLOUD').action='DESELECT'
# 6 - RIGHT
pie.operator("mesh.select_more", text="Select More")
pie.operator("mesh.select_all", text="Select All", icon='OUTLINER_OB_POINTCLOUD').action='SELECT'
# 2 - BOTTOM
pie.menu("VIEW3D_MT_edit_mesh_select_loops")
pie.operator("mesh.select_less", text="Select Less", icon='REMOVE')
# 8 - TOP
pie.operator("mesh.select_all", text="Select All Toggle").action = 'TOGGLE'
pie.operator("mesh.select_more", text="Select More", icon='ADD')
# 7 - TOP - LEFT
pie.operator("view3d.select_circle", text="Circle Select")
pie.operator("mesh.select_linked", text="Select Linked", icon='FILE_3D')
# 9 - TOP - RIGHT
pie.operator("view3d.select_box", text="Box Select")
pie.operator("mesh.select_all", text="Invert Selection", icon='CLIPUV_DEHLT').action='INVERT'
# 1 - BOTTOM - LEFT
pie.operator("mesh.select_all", text="Invert Selection").action = 'INVERT'
pie.separator()
# 3 - BOTTOM - RIGHT
pie.menu("PIE_MT_mesh_selection_mode", text="Edit Modes", icon='VERTEXSEL')
pie.menu("PIE_MT_mesh_selection_more", text="Select Menu", icon='THREE_DOTS')
class PIE_MT_object_selection_more(Menu):
@ -66,57 +63,90 @@ class PIE_MT_object_selection_more(Menu):
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
box = pie.split().column()
box.operator("object.select_random", text="Select Random")
box.operator("object.select_linked", text="Select Linked")
box.separator()
# Modal selection operators.
layout.separator()
layout.operator("view3d.select_circle", text="Circle Select", icon='MESH_CIRCLE')
layout.operator("view3d.select_box", text="Box Select", icon='SELECT_SET')
layout.operator_menu_enum("view3d.select_lasso", "mode", icon='MOD_CURVE')
box.operator("object.select_more", text="More")
box.operator("object.select_less", text="Less")
box.separator()
props = box.operator("object.select_hierarchy", text="Parent")
props.extend = False
props.direction = 'PARENT'
props = box.operator("object.select_hierarchy", text="Child")
props.extend = False
props.direction = 'CHILD'
box.separator()
props = box.operator("object.select_hierarchy", text="Extend Parent")
# Parent/Children selection extend ops.
layout.separator()
props = layout.operator("object.select_hierarchy", text="Add Parent to Selection", icon='FILE_PARENT')
props.extend = True
props.direction = 'PARENT'
props = box.operator("object.select_hierarchy", text="Extend Child")
props = layout.operator("object.select_hierarchy", text="Add Children to Selection", icon='CON_CHILDOF')
props.extend = True
props.direction = 'CHILD'
# Select based on the active object.
layout.separator()
layout.operator_menu_enum("object.select_grouped", "type", text="Select Grouped", icon='OUTLINER_COLLECTION')
layout.operator_menu_enum("object.select_linked", "type", text="Select Linked", icon='DUPLICATE')
class PIE_MT_mesh_selection_mode(Menu):
bl_idname = "PIE_MT_mesh_selection_mode"
# Select based on parameters.
layout.separator()
layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type", icon='OUTLINER_OB_MESH')
layout.operator("object.select_random", text="Select Random", icon='RNDCURVE')
layout.operator("object.select_pattern", text="Select Pattern...", icon='FILTER')
layout.separator()
layout.operator("object.select_camera", text="Select Active Camera", icon='OUTLINER_OB_CAMERA')
class PIE_MT_mesh_selection_more(Menu):
bl_idname = "PIE_MT_mesh_selection_more"
bl_label = "Mesh Selection Mode"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
box = pie.split().column()
box.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
box.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
box.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
vert_mode, edge_mode, face_mode = context.tool_settings.mesh_select_mode
# Selection modes.
layout.operator("mesh.select_mode", text="Vertex Select Mode", icon='VERTEXSEL', depress=vert_mode).type = 'VERT'
layout.operator("mesh.select_mode", text="Edge Select Mode", icon='EDGESEL', depress=edge_mode).type = 'EDGE'
layout.operator("mesh.select_mode", text="Face Select Mode", icon='FACESEL', depress=face_mode).type = 'FACE'
# Modal selection operators.
layout.separator()
layout.operator("view3d.select_circle", text="Circle Select", icon='MESH_CIRCLE')
layout.operator("view3d.select_box", text="Box Select", icon='SELECT_SET')
layout.operator_menu_enum("view3d.select_lasso", "mode", icon='MOD_CURVE')
# Select based on what's active.
layout.separator()
layout.menu("VIEW3D_MT_edit_mesh_select_linked", icon='FILE_3D')
layout.menu("VIEW3D_MT_edit_mesh_select_similar", icon='CON_TRANSLIKE')
layout.operator_menu_enum("mesh.select_axis", "axis", text="Select Side", icon='AXIS_SIDE')
layout.menu("VIEW3D_MT_edit_mesh_select_loops")
layout.operator("mesh.select_nth", text="Checker Deselect", icon='TEXTURE')
# Select based on some parameter.
layout.separator()
layout.menu("VIEW3D_MT_edit_mesh_select_by_trait")
layout.operator("mesh.select_by_attribute", text="Select All By Attribute", icon='GEOMETRY_NODES')
# User-defined GeoNode Select operations.
layout.template_node_operator_asset_menu_items(catalog_path="Select")
registry = [
PIE_MT_object_selection,
PIE_MT_mesh_selection,
PIE_MT_object_selection_more,
PIE_MT_mesh_selection_mode,
PIE_MT_mesh_selection_more,
]
def draw_edge_sharpness_in_traits_menu(self, context):
self.layout.operator("mesh.edges_select_sharp", text="Edge Sharpness")
def register():
# Weird that this built-in operator is not included in this built-in menu.
bpy.types.VIEW3D_MT_edit_mesh_select_by_trait.prepend(draw_edge_sharpness_in_traits_menu)
register_hotkey(
'wm.call_menu_pie',
op_kwargs={'name': 'PIE_MT_object_selection'},
@ -129,3 +159,7 @@ def register():
hotkey_kwargs={'type': "A", 'value': "PRESS"},
key_cat="Mesh",
)
def unregister():
bpy.types.VIEW3D_MT_edit_mesh_select_by_trait.remove(draw_edge_sharpness_in_traits_menu)