add 'Extrude Region, Vertex Normal' to the extrude menu, equivalent of 'Extrude, Escape, Alt+S'

This commit is contained in:
Campbell Barton 2013-10-15 18:30:49 +00:00
parent cd6477eee0
commit ac602142d3
3 changed files with 45 additions and 10 deletions

@ -62,7 +62,8 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
bl_label = "Extrude and Move on Normals"
bl_idname = "view3d.edit_mesh_extrude_move_normal"
def execute(self, context):
@staticmethod
def extrude_region(context, use_vert_normals):
mesh = context.object.data
totface = mesh.total_face_sel
@ -70,10 +71,15 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
#~ totvert = mesh.total_vert_sel
if totface >= 1:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"constraint_orientation": 'NORMAL',
"constraint_axis": (False, False, True)})
if use_vert_normals:
bpy.ops.mesh.extrude_region_shrink_fatten('INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={})
else:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"constraint_orientation": 'NORMAL',
"constraint_axis": (False, False, True)})
elif totedge == 1:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
@ -88,6 +94,22 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
# and cause this one not to be freed. [#24671]
return {'FINISHED'}
def execute(self, context):
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, False)
def invoke(self, context, event):
return self.execute(context)
class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator):
"Extrude and move along individual normals"
bl_label = "Extrude and Move on Individual Normals"
bl_idname = "view3d.edit_mesh_extrude_move_shrink_fatten"
def execute(self, context):
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True)
def invoke(self, context, event):
return self.execute(context)

@ -1909,10 +1909,16 @@ class VIEW3D_MT_edit_mesh_extrude(Menu):
bl_label = "Extrude"
_extrude_funcs = {
'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
'VERT': lambda layout:
layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
'EDGE': lambda layout:
layout.operator("mesh.extrude_edges_move", text="Edges Only"),
'FACE': lambda layout:
layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
'REGION': lambda layout:
layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
'REGION_VERT_NORMAL': lambda layout:
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Region (Vertex Normals)"),
}
@staticmethod
@ -1922,7 +1928,7 @@ class VIEW3D_MT_edit_mesh_extrude(Menu):
menu = []
if mesh.total_face_sel:
menu += ['REGION', 'FACE']
menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE']
if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
menu += ['EDGE']
if mesh.total_vert_sel and select_mode[0]:

@ -244,6 +244,13 @@ void ED_operatormacros_mesh(void)
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten", "Extrude Region and Shrink/Fatten",
"Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move",
"Extrude faces and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");