1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
7 "description": "Object/Edit mode Selection Menu",
8 "author": "pitiwazou, meta-androcto",
10 "blender": (2, 80, 0),
11 "location": "3D View",
14 "category": "Select Pie"
18 from bpy
.types
import (
24 # Pie Selection Object Mode - A
25 class PIE_MT_SelectionsMore(Menu
):
26 bl_idname
= "PIE_MT_selectionsmore"
27 bl_label
= "Pie Selections Object Mode"
29 def draw(self
, context
):
31 pie
= layout
.menu_pie()
32 box
= pie
.split().column()
33 box
.operator("object.select_random", text
="Select Random")
34 box
.operator("object.select_linked", text
="Select Linked")
37 box
.operator("object.select_more", text
="More")
38 box
.operator("object.select_less", text
="Less")
41 props
= box
.operator("object.select_hierarchy", text
="Parent")
43 props
.direction
= 'PARENT'
45 props
= box
.operator("object.select_hierarchy", text
="Child")
47 props
.direction
= 'CHILD'
50 props
= box
.operator("object.select_hierarchy", text
="Extend Parent")
52 props
.direction
= 'PARENT'
54 props
= box
.operator("object.select_hierarchy", text
="Extend Child")
56 props
.direction
= 'CHILD'
58 # Pie Selection Object Mode - A
61 class PIE_MT_SelectionsOM(Menu
):
62 bl_idname
= "PIE_MT_selectionsom"
63 bl_label
= "Pie Selections Object Mode"
65 def draw(self
, context
):
67 pie
= layout
.menu_pie()
69 pie
.operator("object.select_grouped", text
="Select Grouped")
71 pie
.operator("object.select_by_type", text
="Select By Type")
73 pie
.operator("object.select_all", text
="Invert Selection", icon
='ZOOM_PREVIOUS').action
= 'INVERT'
75 pie
.operator("object.select_all", text
="Select All Toggle", icon
='NONE').action
= 'TOGGLE'
77 pie
.operator("view3d.select_circle", text
="Circle Select")
79 pie
.operator("view3d.select_box", text
="Box Select")
81 pie
.operator("object.select_camera", text
="Select Camera")
83 pie
.menu("PIE_MT_selectionsmore", text
="Select Menu")
86 # Pie Selection Edit Mode
87 class PIE_MT_SelectionsEM(Menu
):
88 bl_idname
= "PIE_MT_selectionsem"
89 bl_label
= "Pie Selections Edit Mode"
91 def draw(self
, context
):
93 pie
= layout
.menu_pie()
95 pie
.operator("mesh.select_less", text
="Select Less")
97 pie
.operator("mesh.select_more", text
="Select More")
99 pie
.menu("OBJECT_MT_selectloopselection", text
="Select Loop Menu")
101 pie
.operator("mesh.select_all", text
="Select All Toggle").action
= 'TOGGLE'
103 pie
.operator("view3d.select_circle", text
="Circle Select")
105 pie
.operator("view3d.select_box", text
="Box Select")
107 pie
.operator("mesh.select_all", text
="Invert Selection").action
= 'INVERT'
109 pie
.menu("PIE_MT_selectallbyselection", text
="Edit Modes", icon
='VERTEXSEL')
112 # Select All By Selection
113 class PIE_MT_SelectAllBySelection(Menu
):
114 bl_idname
= "PIE_MT_selectallbyselection"
115 bl_label
= "Verts Edges Faces"
117 def draw(self
, context
):
119 pie
= layout
.menu_pie()
120 box
= pie
.split().column()
122 box
.operator("class.vertexop", text
="Vertex", icon
='VERTEXSEL')
123 box
.operator("class.edgeop", text
="Edge", icon
='EDGESEL')
124 box
.operator("class.faceop", text
="Face", icon
='FACESEL')
125 box
.operator("verts.edgesfacesop", text
="Vertex/Edges/Faces", icon
='OBJECT_DATAMODE')
128 # Edit Selection Modes
129 class PIE_OT_classvertexop(Operator
):
130 bl_idname
= "class.vertexop"
131 bl_label
= "Class Vertex"
132 bl_description
= "Vert Select Mode"
133 bl_options
= {'REGISTER', 'UNDO'}
135 def execute(self
, context
):
136 if context
.object.mode
!= "EDIT":
137 bpy
.ops
.object.mode_set(mode
="EDIT")
138 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
139 if bpy
.ops
.mesh
.select_mode
!= "EDGE, FACE":
140 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
144 class PIE_OT_classedgeop(Operator
):
145 bl_idname
= "class.edgeop"
146 bl_label
= "Class Edge"
147 bl_description
= "Edge Select Mode"
148 bl_options
= {'REGISTER', 'UNDO'}
150 def execute(self
, context
):
151 if context
.object.mode
!= "EDIT":
152 bpy
.ops
.object.mode_set(mode
="EDIT")
153 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='EDGE')
154 if bpy
.ops
.mesh
.select_mode
!= "VERT, FACE":
155 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='EDGE')
159 class PIE_OT_classfaceop(Operator
):
160 bl_idname
= "class.faceop"
161 bl_label
= "Class Face"
162 bl_description
= "Face Select Mode"
163 bl_options
= {'REGISTER', 'UNDO'}
165 def execute(self
, context
):
166 if context
.object.mode
!= "EDIT":
167 bpy
.ops
.object.mode_set(mode
="EDIT")
168 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='FACE')
169 if bpy
.ops
.mesh
.select_mode
!= "VERT, EDGE":
170 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='FACE')
174 # Combined Selection Mode
175 class PIE_OT_vertsedgesfacesop(Operator
):
176 bl_idname
= "verts.edgesfacesop"
177 bl_label
= "Verts Edges Faces"
178 bl_description
= "Vert/Edge/Face Select Mode"
179 bl_options
= {'REGISTER', 'UNDO'}
181 def execute(self
, context
):
182 if context
.object.mode
!= "EDIT":
183 bpy
.ops
.object.mode_set(mode
="EDIT")
184 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
185 if bpy
.ops
.mesh
.select_mode
!= "VERT, EDGE, FACE":
186 bpy
.ops
.object.mode_set(mode
="EDIT")
187 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
188 bpy
.ops
.mesh
.select_mode(use_extend
=True, use_expand
=False, type='EDGE')
189 bpy
.ops
.mesh
.select_mode(use_extend
=True, use_expand
=False, type='FACE')
193 class PIE_MT_SelectLoopSelection(Menu
):
194 bl_idname
= "OBJECT_MT_selectloopselection"
195 bl_label
= "Verts Edges Faces"
197 def draw(self
, context
):
199 layout
.operator_context
= 'INVOKE_REGION_WIN'
201 layout
.operator("mesh.loop_multi_select", text
="Select Loop", icon
='NONE').ring
= False
202 layout
.operator("mesh.loop_multi_select", text
="Select Ring", icon
='NONE').ring
= True
203 layout
.operator("mesh.loop_to_region", text
="Select Loop Inner Region", icon
='NONE')
209 PIE_MT_SelectAllBySelection
,
210 PIE_MT_SelectionsMore
,
211 PIE_MT_SelectLoopSelection
,
212 PIE_OT_classvertexop
,
215 PIE_OT_vertsedgesfacesop
223 bpy
.utils
.register_class(cls
)
225 wm
= bpy
.context
.window_manager
226 if wm
.keyconfigs
.addon
:
227 # Selection Object Mode
228 km
= wm
.keyconfigs
.addon
.keymaps
.new(name
='Object Mode')
229 kmi
= km
.keymap_items
.new('wm.call_menu_pie', 'A', 'PRESS')
230 kmi
.properties
.name
= "PIE_MT_selectionsom"
231 addon_keymaps
.append((km
, kmi
))
233 # Selection Edit Mode
234 km
= wm
.keyconfigs
.addon
.keymaps
.new(name
='Mesh')
235 kmi
= km
.keymap_items
.new('wm.call_menu_pie', 'A', 'PRESS')
236 kmi
.properties
.name
= "PIE_MT_selectionsem"
237 addon_keymaps
.append((km
, kmi
))
242 bpy
.utils
.unregister_class(cls
)
244 wm
= bpy
.context
.window_manager
245 kc
= wm
.keyconfigs
.addon
247 for km
, kmi
in addon_keymaps
:
248 km
.keymap_items
.remove(kmi
)
249 addon_keymaps
.clear()
252 if __name__
== "__main__":