1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
18 # Contributed to by: meta-androcto, JayDez, sim88, sam, lijenstina, mkb, wisaac, CoDEmanX #
22 from bpy
.types
import (
26 from bpy
.props
import (
31 from .object_menus
import *
32 from .snap_origin_cursor
import *
37 # ********** Edit Multiselect **********
38 class VIEW3D_MT_Edit_Multi(Menu
):
39 bl_label
= "Mode Select"
41 def draw(self
, context
):
44 layout
.operator("selectedit.vertex", text
="Vertex", icon
='VERTEXSEL')
45 layout
.operator("selectedit.edge", text
="Edge", icon
='EDGESEL')
46 layout
.operator("selectedit.face", text
="Face", icon
='FACESEL')
47 layout
.operator("selectedit.vertsfaces", text
="Vertex/Faces", icon
='VERTEXSEL')
48 layout
.operator("selectedit.vertsedges", text
="Vertex/Edges", icon
='EDGESEL')
49 layout
.operator("selectedit.edgesfaces", text
="Edges/Faces", icon
='FACESEL')
50 layout
.operator("selectedit.vertsedgesfaces", text
="Vertex/Edges/Faces", icon
='OBJECT_DATAMODE')
53 # ********** Edit Mesh Edge **********
54 class VIEW3D_MT_EditM_Edge(Menu
):
57 def draw(self
, context
):
59 layout
.operator_context
= 'INVOKE_REGION_WIN'
61 layout
.operator("mesh.mark_seam")
62 layout
.operator("mesh.mark_seam", text
="Clear Seam").clear
= True
65 layout
.operator("mesh.mark_sharp")
66 layout
.operator("mesh.mark_sharp", text
="Clear Sharp").clear
= True
67 layout
.operator("mesh.extrude_move_along_normals", text
="Extrude")
70 layout
.operator("mesh.edge_rotate",
71 text
="Rotate Edge CW").direction
= 'CW'
72 layout
.operator("mesh.edge_rotate",
73 text
="Rotate Edge CCW").direction
= 'CCW'
76 layout
.operator("TFM_OT_edge_slide", text
="Edge Slide")
77 layout
.operator("mesh.loop_multi_select", text
="Edge Loop")
78 layout
.operator("mesh.loop_multi_select", text
="Edge Ring").ring
= True
79 layout
.operator("mesh.loop_to_region")
80 layout
.operator("mesh.region_to_loop")
83 # multiple edit select modes.
84 class VIEW3D_OT_selecteditVertex(Operator
):
85 bl_idname
= "selectedit.vertex"
86 bl_label
= "Vertex Mode"
87 bl_description
= "Vert Select"
88 bl_options
= {'REGISTER', 'UNDO'}
90 def execute(self
, context
):
91 if context
.object.mode
!= "EDIT":
92 bpy
.ops
.object.mode_set(mode
="EDIT")
93 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
94 if bpy
.ops
.mesh
.select_mode
!= "EDGE, FACE":
95 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
99 class VIEW3D_OT_selecteditEdge(Operator
):
100 bl_idname
= "selectedit.edge"
101 bl_label
= "Edge Mode"
102 bl_description
= "Edge Select"
103 bl_options
= {'REGISTER', 'UNDO'}
105 def execute(self
, context
):
106 if context
.object.mode
!= "EDIT":
107 bpy
.ops
.object.mode_set(mode
="EDIT")
108 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='EDGE')
109 if bpy
.ops
.mesh
.select_mode
!= "VERT, FACE":
110 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='EDGE')
114 class VIEW3D_OT_selecteditFace(Operator
):
115 bl_idname
= "selectedit.face"
116 bl_label
= "Multiedit Face"
117 bl_description
= "Face Mode"
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='FACE')
124 if bpy
.ops
.mesh
.select_mode
!= "VERT, EDGE":
125 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='FACE')
129 # Components Multi Selection Mode
130 class VIEW3D_OT_selecteditVertsEdges(Operator
):
131 bl_idname
= "selectedit.vertsedges"
132 bl_label
= "Verts Edges Mode"
133 bl_description
= "Vert/Edge Select"
134 bl_options
= {'REGISTER', 'UNDO'}
136 def execute(self
, context
):
137 if context
.object.mode
!= "EDIT":
138 bpy
.ops
.object.mode_set(mode
="EDIT")
139 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
140 if bpy
.ops
.mesh
.select_mode
!= "VERT, EDGE, FACE":
141 bpy
.ops
.object.mode_set(mode
="EDIT")
142 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
143 bpy
.ops
.mesh
.select_mode(use_extend
=True, use_expand
=False, type='EDGE')
147 class VIEW3D_OT_selecteditEdgesFaces(Operator
):
148 bl_idname
= "selectedit.edgesfaces"
149 bl_label
= "Edges Faces Mode"
150 bl_description
= "Edge/Face Select"
151 bl_options
= {'REGISTER', 'UNDO'}
153 def execute(self
, context
):
154 if context
.object.mode
!= "EDIT":
155 bpy
.ops
.object.mode_set(mode
="EDIT")
156 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='EDGE')
157 if bpy
.ops
.mesh
.select_mode
!= "VERT, EDGE, FACE":
158 bpy
.ops
.object.mode_set(mode
="EDIT")
159 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='EDGE')
160 bpy
.ops
.mesh
.select_mode(use_extend
=True, use_expand
=False, type='FACE')
164 class VIEW3D_OT_selecteditVertsFaces(Operator
):
165 bl_idname
= "selectedit.vertsfaces"
166 bl_label
= "Verts Faces Mode"
167 bl_description
= "Vert/Face Select"
168 bl_options
= {'REGISTER', 'UNDO'}
170 def execute(self
, context
):
171 if context
.object.mode
!= "EDIT":
172 bpy
.ops
.object.mode_set(mode
="EDIT")
173 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
174 if bpy
.ops
.mesh
.select_mode
!= "VERT, EDGE, FACE":
175 bpy
.ops
.object.mode_set(mode
="EDIT")
176 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
177 bpy
.ops
.mesh
.select_mode(use_extend
=True, use_expand
=False, type='FACE')
181 class VIEW3D_OT_selecteditVertsEdgesFaces(Operator
):
182 bl_idname
= "selectedit.vertsedgesfaces"
183 bl_label
= "Verts Edges Faces Mode"
184 bl_description
= "Vert/Edge/Face Select"
185 bl_options
= {'REGISTER', 'UNDO'}
187 def execute(self
, context
):
188 if context
.object.mode
!= "EDIT":
189 bpy
.ops
.object.mode_set(mode
="EDIT")
190 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
191 if bpy
.ops
.mesh
.select_mode
!= "VERT, EDGE, FACE":
192 bpy
.ops
.object.mode_set(mode
="EDIT")
193 bpy
.ops
.mesh
.select_mode(use_extend
=False, use_expand
=False, type='VERT')
194 bpy
.ops
.mesh
.select_mode(use_extend
=True, use_expand
=False, type='EDGE')
195 bpy
.ops
.mesh
.select_mode(use_extend
=True, use_expand
=False, type='FACE')
199 # ********** Normals / Auto Smooth Menu **********
200 # Thanks to marvin.k.breuer for the Autosmooth part of the menu
202 def menu_func(self
, context
):
205 obj_data
= context
.active_object
.data
207 layout
.prop(obj_data
, "use_auto_smooth", text
="Normals: Auto Smooth")
209 # Auto Smooth Angle - two tab spaces to align it with the rest of the menu
210 layout
.prop(obj_data
, "auto_smooth_angle",
211 text
=" Auto Smooth Angle")
217 VIEW3D_MT_Edit_Multi
,
218 VIEW3D_MT_EditM_Edge
,
219 VIEW3D_OT_selecteditVertex
,
220 VIEW3D_OT_selecteditEdge
,
221 VIEW3D_OT_selecteditFace
,
222 VIEW3D_OT_selecteditVertsEdges
,
223 VIEW3D_OT_selecteditEdgesFaces
,
224 VIEW3D_OT_selecteditVertsFaces
,
225 VIEW3D_OT_selecteditVertsEdgesFaces
,
229 # Register Classes & Hotkeys #
232 bpy
.utils
.register_class(cls
)
234 bpy
.types
.VIEW3D_MT_edit_mesh_normals
.append(menu_func
)
236 # Unregister Classes & Hotkeys #
239 for cls
in reversed(classes
):
240 bpy
.utils
.unregister_class(cls
)
242 bpy
.types
.VIEW3D_MT_edit_mesh_normals
.remove(menu_func
)
244 if __name__
== "__main__":