Import images: add file handler
[blender-addons.git] / space_view3d_pie_menus / pie_select_menu.py
blob4ac4400a8625cbd3f578634e83f6148a0034c2a8
1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 bl_info = {
6 "name": "Hotkey: 'A'",
7 "description": "Object/Edit mode Selection Menu",
8 "author": "pitiwazou, meta-androcto",
9 "version": (0, 1, 1),
10 "blender": (2, 80, 0),
11 "location": "3D View",
12 "warning": "",
13 "doc_url": "",
14 "category": "Select Pie"
17 import bpy
18 from bpy.types import (
19 Menu,
20 Operator
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):
30 layout = self.layout
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")
35 box.separator()
37 box.operator("object.select_more", text="More")
38 box.operator("object.select_less", text="Less")
39 box.separator()
41 props = box.operator("object.select_hierarchy", text="Parent")
42 props.extend = False
43 props.direction = 'PARENT'
45 props = box.operator("object.select_hierarchy", text="Child")
46 props.extend = False
47 props.direction = 'CHILD'
48 box.separator()
50 props = box.operator("object.select_hierarchy", text="Extend Parent")
51 props.extend = True
52 props.direction = 'PARENT'
54 props = box.operator("object.select_hierarchy", text="Extend Child")
55 props.extend = True
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):
66 layout = self.layout
67 pie = layout.menu_pie()
68 # 4 - LEFT
69 pie.operator("object.select_grouped", text="Select Grouped")
70 # 6 - RIGHT
71 pie.operator("object.select_by_type", text="Select By Type")
72 # 2 - BOTTOM
73 pie.operator("object.select_all", text="Invert Selection", icon='ZOOM_PREVIOUS').action = 'INVERT'
74 # 8 - TOP
75 pie.operator("object.select_all", text="Select All Toggle", icon='NONE').action = 'TOGGLE'
76 # 7 - TOP - LEFT
77 pie.operator("view3d.select_circle", text="Circle Select")
78 # 9 - TOP - RIGHT
79 pie.operator("view3d.select_box", text="Box Select")
80 # 1 - BOTTOM - LEFT
81 pie.operator("object.select_camera", text="Select Camera")
82 # 3 - BOTTOM - RIGHT
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):
92 layout = self.layout
93 pie = layout.menu_pie()
94 # 4 - LEFT
95 pie.operator("mesh.select_less", text="Select Less")
96 # 6 - RIGHT
97 pie.operator("mesh.select_more", text="Select More")
98 # 2 - BOTTOM
99 pie.menu("OBJECT_MT_selectloopselection", text="Select Loop Menu")
100 # 8 - TOP
101 pie.operator("mesh.select_all", text="Select All Toggle").action = 'TOGGLE'
102 # 7 - TOP - LEFT
103 pie.operator("view3d.select_circle", text="Circle Select")
104 # 9 - TOP - RIGHT
105 pie.operator("view3d.select_box", text="Box Select")
106 # 1 - BOTTOM - LEFT
107 pie.operator("mesh.select_all", text="Invert Selection").action = 'INVERT'
108 # 3 - BOTTOM - RIGHT
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):
118 layout = self.layout
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')
141 return {'FINISHED'}
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')
156 return {'FINISHED'}
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')
171 return {'FINISHED'}
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')
190 return {'FINISHED'}
193 class PIE_MT_SelectLoopSelection(Menu):
194 bl_idname = "OBJECT_MT_selectloopselection"
195 bl_label = "Verts Edges Faces"
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()