Cleanup: autopep8 format pie menus
[blender-addons.git] / space_view3d_pie_menus / pie_select_menu.py
blobcf596053eb9031f9d8fb66d2cf738625fcdb8590
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 bl_info = {
4 "name": "Hotkey: 'A'",
5 "description": "Object/Edit mode Selection Menu",
6 "author": "pitiwazou, meta-androcto",
7 "version": (0, 1, 1),
8 "blender": (2, 80, 0),
9 "location": "3D View",
10 "warning": "",
11 "doc_url": "",
12 "category": "Select Pie"
15 import bpy
16 from bpy.types import (
17 Menu,
18 Operator
22 # Pie Selection Object Mode - A
23 class PIE_MT_SelectionsMore(Menu):
24 bl_idname = "PIE_MT_selectionsmore"
25 bl_label = "Pie Selections Object Mode"
27 def draw(self, context):
28 layout = self.layout
29 pie = layout.menu_pie()
30 box = pie.split().column()
31 box.operator("object.select_random", text="Select Random")
32 box.operator("object.select_linked", text="Select Linked")
33 box.separator()
35 box.operator("object.select_more", text="More")
36 box.operator("object.select_less", text="Less")
37 box.separator()
39 props = box.operator("object.select_hierarchy", text="Parent")
40 props.extend = False
41 props.direction = 'PARENT'
43 props = box.operator("object.select_hierarchy", text="Child")
44 props.extend = False
45 props.direction = 'CHILD'
46 box.separator()
48 props = box.operator("object.select_hierarchy", text="Extend Parent")
49 props.extend = True
50 props.direction = 'PARENT'
52 props = box.operator("object.select_hierarchy", text="Extend Child")
53 props.extend = True
54 props.direction = 'CHILD'
56 # Pie Selection Object Mode - A
59 class PIE_MT_SelectionsOM(Menu):
60 bl_idname = "PIE_MT_selectionsom"
61 bl_label = "Pie Selections Object Mode"
63 def draw(self, context):
64 layout = self.layout
65 pie = layout.menu_pie()
66 # 4 - LEFT
67 pie.operator("object.select_grouped", text="Select Grouped")
68 # 6 - RIGHT
69 pie.operator("object.select_by_type", text="Select By Type")
70 # 2 - BOTTOM
71 pie.operator("object.select_all", text="Invert Selection", icon='ZOOM_PREVIOUS').action = 'INVERT'
72 # 8 - TOP
73 pie.operator("object.select_all", text="Select All Toggle", icon='NONE').action = 'TOGGLE'
74 # 7 - TOP - LEFT
75 pie.operator("view3d.select_circle", text="Circle Select")
76 # 9 - TOP - RIGHT
77 pie.operator("view3d.select_box", text="Box Select")
78 # 1 - BOTTOM - LEFT
79 pie.operator("object.select_camera", text="Select Camera")
80 # 3 - BOTTOM - RIGHT
81 pie.menu("PIE_MT_selectionsmore", text="Select Menu")
84 # Pie Selection Edit Mode
85 class PIE_MT_SelectionsEM(Menu):
86 bl_idname = "PIE_MT_selectionsem"
87 bl_label = "Pie Selections Edit Mode"
89 def draw(self, context):
90 layout = self.layout
91 pie = layout.menu_pie()
92 # 4 - LEFT
93 pie.operator("mesh.select_less", text="Select Less")
94 # 6 - RIGHT
95 pie.operator("mesh.select_more", text="Select More")
96 # 2 - BOTTOM
97 pie.menu("OBJECT_MT_selectloopselection", text="Select Loop Menu")
98 # 8 - TOP
99 pie.operator("mesh.select_all", text="Select All Toggle").action = 'TOGGLE'
100 # 7 - TOP - LEFT
101 pie.operator("view3d.select_circle", text="Circle Select")
102 # 9 - TOP - RIGHT
103 pie.operator("view3d.select_box", text="Box Select")
104 # 1 - BOTTOM - LEFT
105 pie.operator("mesh.select_all", text="Invert Selection").action = 'INVERT'
106 # 3 - BOTTOM - RIGHT
107 pie.menu("PIE_MT_selectallbyselection", text="Edit Modes", icon='VERTEXSEL')
110 # Select All By Selection
111 class PIE_MT_SelectAllBySelection(Menu):
112 bl_idname = "PIE_MT_selectallbyselection"
113 bl_label = "Verts Edges Faces"
114 bl_options = {'REGISTER', 'UNDO'}
116 def draw(self, context):
117 layout = self.layout
118 pie = layout.menu_pie()
119 box = pie.split().column()
121 box.operator("class.vertexop", text="Vertex", icon='VERTEXSEL')
122 box.operator("class.edgeop", text="Edge", icon='EDGESEL')
123 box.operator("class.faceop", text="Face", icon='FACESEL')
124 box.operator("verts.edgesfacesop", text="Vertex/Edges/Faces", icon='OBJECT_DATAMODE')
127 # Edit Selection Modes
128 class PIE_OT_classvertexop(Operator):
129 bl_idname = "class.vertexop"
130 bl_label = "Class Vertex"
131 bl_description = "Vert Select Mode"
132 bl_options = {'REGISTER', 'UNDO'}
134 def execute(self, context):
135 if context.object.mode != "EDIT":
136 bpy.ops.object.mode_set(mode="EDIT")
137 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
138 if bpy.ops.mesh.select_mode != "EDGE, FACE":
139 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
140 return {'FINISHED'}
143 class PIE_OT_classedgeop(Operator):
144 bl_idname = "class.edgeop"
145 bl_label = "Class Edge"
146 bl_description = "Edge Select Mode"
147 bl_options = {'REGISTER', 'UNDO'}
149 def execute(self, context):
150 if context.object.mode != "EDIT":
151 bpy.ops.object.mode_set(mode="EDIT")
152 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
153 if bpy.ops.mesh.select_mode != "VERT, FACE":
154 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
155 return {'FINISHED'}
158 class PIE_OT_classfaceop(Operator):
159 bl_idname = "class.faceop"
160 bl_label = "Class Face"
161 bl_description = "Face Select Mode"
162 bl_options = {'REGISTER', 'UNDO'}
164 def execute(self, context):
165 if context.object.mode != "EDIT":
166 bpy.ops.object.mode_set(mode="EDIT")
167 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
168 if bpy.ops.mesh.select_mode != "VERT, EDGE":
169 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
170 return {'FINISHED'}
173 # Combined Selection Mode
174 class PIE_OT_vertsedgesfacesop(Operator):
175 bl_idname = "verts.edgesfacesop"
176 bl_label = "Verts Edges Faces"
177 bl_description = "Vert/Edge/Face Select Mode"
178 bl_options = {'REGISTER', 'UNDO'}
180 def execute(self, context):
181 if context.object.mode != "EDIT":
182 bpy.ops.object.mode_set(mode="EDIT")
183 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
184 if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
185 bpy.ops.object.mode_set(mode="EDIT")
186 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
187 bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE')
188 bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
189 return {'FINISHED'}
192 class PIE_MT_SelectLoopSelection(Menu):
193 bl_idname = "OBJECT_MT_selectloopselection"
194 bl_label = "Verts Edges Faces"
195 bl_options = {'REGISTER', 'UNDO'}
197 def draw(self, context):
198 layout = self.layout
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')
206 classes = (
207 PIE_MT_SelectionsOM,
208 PIE_MT_SelectionsEM,
209 PIE_MT_SelectAllBySelection,
210 PIE_MT_SelectionsMore,
211 PIE_MT_SelectLoopSelection,
212 PIE_OT_classvertexop,
213 PIE_OT_classedgeop,
214 PIE_OT_classfaceop,
215 PIE_OT_vertsedgesfacesop
218 addon_keymaps = []
221 def register():
222 for cls in classes:
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))
240 def unregister():
241 for cls in classes:
242 bpy.utils.unregister_class(cls)
244 wm = bpy.context.window_manager
245 kc = wm.keyconfigs.addon
246 if kc:
247 for km, kmi in addon_keymaps:
248 km.keymap_items.remove(kmi)
249 addon_keymaps.clear()
252 if __name__ == "__main__":
253 register()