Cleanup: autopep8 for 3DS i/o
[blender-addons.git] / space_view3d_spacebar_menu / edit_mesh.py
blobf40e8b9ad7f9dacb9b2e3d66cd3d8534232615e9
1 # SPDX-License-Identifier: GPL-2.0-or-later
2 # Contributed to by: meta-androcto, JayDez, sim88, sam, lijenstina, mkb, wisaac, CoDEmanX.
5 import bpy
6 from bpy.types import (
7 Operator,
8 Menu,
10 from bpy.props import (
11 BoolProperty,
12 StringProperty,
15 from .object_menus import *
16 from .snap_origin_cursor import *
19 # Edit Mode Menu's #
21 # ********** Edit Multiselect **********
22 class VIEW3D_MT_Edit_Multi(Menu):
23 bl_label = "Mode Select"
25 def draw(self, context):
26 layout = self.layout
28 layout.operator("selectedit.vertex", text="Vertex", icon='VERTEXSEL')
29 layout.operator("selectedit.edge", text="Edge", icon='EDGESEL')
30 layout.operator("selectedit.face", text="Face", icon='FACESEL')
31 layout.operator("selectedit.vertsfaces", text="Vertex/Faces", icon='VERTEXSEL')
32 layout.operator("selectedit.vertsedges", text="Vertex/Edges", icon='EDGESEL')
33 layout.operator("selectedit.edgesfaces", text="Edges/Faces", icon='FACESEL')
34 layout.operator("selectedit.vertsedgesfaces", text="Vertex/Edges/Faces", icon='OBJECT_DATAMODE')
37 # ********** Edit Mesh Edge **********
38 class VIEW3D_MT_EditM_Edge(Menu):
39 bl_label = "Edges"
41 def draw(self, context):
42 layout = self.layout
43 layout.operator_context = 'INVOKE_REGION_WIN'
45 layout.operator("mesh.mark_seam")
46 layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
47 layout.separator()
49 layout.operator("mesh.mark_sharp")
50 layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
51 layout.operator("mesh.extrude_move_along_normals", text="Extrude")
52 layout.separator()
54 layout.operator("mesh.edge_rotate",
55 text="Rotate Edge CW").direction = 'CW'
56 layout.operator("mesh.edge_rotate",
57 text="Rotate Edge CCW").direction = 'CCW'
58 layout.separator()
60 layout.operator("TFM_OT_edge_slide", text="Edge Slide")
61 layout.operator("mesh.loop_multi_select", text="Edge Loop")
62 layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
63 layout.operator("mesh.loop_to_region")
64 layout.operator("mesh.region_to_loop")
67 # multiple edit select modes.
68 class VIEW3D_OT_selecteditVertex(Operator):
69 bl_idname = "selectedit.vertex"
70 bl_label = "Vertex Mode"
71 bl_description = "Vert Select"
72 bl_options = {'REGISTER', 'UNDO'}
74 def execute(self, context):
75 if context.object.mode != "EDIT":
76 bpy.ops.object.mode_set(mode="EDIT")
77 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
78 if bpy.ops.mesh.select_mode != "EDGE, FACE":
79 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
80 return {'FINISHED'}
83 class VIEW3D_OT_selecteditEdge(Operator):
84 bl_idname = "selectedit.edge"
85 bl_label = "Edge Mode"
86 bl_description = "Edge Select"
87 bl_options = {'REGISTER', 'UNDO'}
89 def execute(self, context):
90 if context.object.mode != "EDIT":
91 bpy.ops.object.mode_set(mode="EDIT")
92 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
93 if bpy.ops.mesh.select_mode != "VERT, FACE":
94 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
95 return {'FINISHED'}
98 class VIEW3D_OT_selecteditFace(Operator):
99 bl_idname = "selectedit.face"
100 bl_label = "Multiedit Face"
101 bl_description = "Face Mode"
102 bl_options = {'REGISTER', 'UNDO'}
104 def execute(self, context):
105 if context.object.mode != "EDIT":
106 bpy.ops.object.mode_set(mode="EDIT")
107 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
108 if bpy.ops.mesh.select_mode != "VERT, EDGE":
109 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
110 return {'FINISHED'}
113 # Components Multi Selection Mode
114 class VIEW3D_OT_selecteditVertsEdges(Operator):
115 bl_idname = "selectedit.vertsedges"
116 bl_label = "Verts Edges Mode"
117 bl_description = "Vert/Edge Select"
118 bl_options = {'REGISTER', 'UNDO'}
120 def execute(self, context):
121 if context.object.mode != "EDIT":
122 bpy.ops.object.mode_set(mode="EDIT")
123 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
124 if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
125 bpy.ops.object.mode_set(mode="EDIT")
126 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
127 bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE')
128 return {'FINISHED'}
131 class VIEW3D_OT_selecteditEdgesFaces(Operator):
132 bl_idname = "selectedit.edgesfaces"
133 bl_label = "Edges Faces Mode"
134 bl_description = "Edge/Face Select"
135 bl_options = {'REGISTER', 'UNDO'}
137 def execute(self, context):
138 if context.object.mode != "EDIT":
139 bpy.ops.object.mode_set(mode="EDIT")
140 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
141 if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
142 bpy.ops.object.mode_set(mode="EDIT")
143 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
144 bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
145 return {'FINISHED'}
148 class VIEW3D_OT_selecteditVertsFaces(Operator):
149 bl_idname = "selectedit.vertsfaces"
150 bl_label = "Verts Faces Mode"
151 bl_description = "Vert/Face Select"
152 bl_options = {'REGISTER', 'UNDO'}
154 def execute(self, context):
155 if context.object.mode != "EDIT":
156 bpy.ops.object.mode_set(mode="EDIT")
157 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
158 if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
159 bpy.ops.object.mode_set(mode="EDIT")
160 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
161 bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
162 return {'FINISHED'}
165 class VIEW3D_OT_selecteditVertsEdgesFaces(Operator):
166 bl_idname = "selectedit.vertsedgesfaces"
167 bl_label = "Verts Edges Faces Mode"
168 bl_description = "Vert/Edge/Face Select"
169 bl_options = {'REGISTER', 'UNDO'}
171 def execute(self, context):
172 if context.object.mode != "EDIT":
173 bpy.ops.object.mode_set(mode="EDIT")
174 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
175 if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE":
176 bpy.ops.object.mode_set(mode="EDIT")
177 bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
178 bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE')
179 bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE')
180 return {'FINISHED'}
183 # ********** Normals / Auto Smooth Menu **********
184 # Thanks to marvin.k.breuer for the Autosmooth part of the menu
186 def menu_func(self, context):
187 layout = self.layout
188 obj = context.object
189 obj_data = context.active_object.data
190 layout.separator()
191 layout.prop(obj_data, "use_auto_smooth", text="Normals: Auto Smooth")
193 # Auto Smooth Angle - two tab spaces to align it with the rest of the menu
194 layout.prop(obj_data, "auto_smooth_angle",
195 text=" Auto Smooth Angle")
198 # List The Classes #
200 classes = (
201 VIEW3D_MT_Edit_Multi,
202 VIEW3D_MT_EditM_Edge,
203 VIEW3D_OT_selecteditVertex,
204 VIEW3D_OT_selecteditEdge,
205 VIEW3D_OT_selecteditFace,
206 VIEW3D_OT_selecteditVertsEdges,
207 VIEW3D_OT_selecteditEdgesFaces,
208 VIEW3D_OT_selecteditVertsFaces,
209 VIEW3D_OT_selecteditVertsEdgesFaces,
213 # Register Classes & Hotkeys #
214 def register():
215 for cls in classes:
216 bpy.utils.register_class(cls)
218 bpy.types.VIEW3D_MT_edit_mesh_normals.append(menu_func)
220 # Unregister Classes & Hotkeys #
221 def unregister():
223 for cls in reversed(classes):
224 bpy.utils.unregister_class(cls)
226 bpy.types.VIEW3D_MT_edit_mesh_normals.remove(menu_func)
228 if __name__ == "__main__":
229 register()