Código:
#description for add-on menú.
Dynamic 3d view menú (double right click in view3d).
Import Bpy.
#import dynamic_menu.
Class view3d_mt_tols(Bpy, types. Menu):
Bl_label =
Def draw(self, context):
Layout = self, Layout.
Layout, operator_context = invoke_region_win.
Ob = context.
If ob, mode == object:
Layout, operator(Mesh, primitive_plane_add).
Layout, operator(Mesh, primitive_cube_add).
Layout, operator(Mesh, primitive_circle_add).
Layout, operator(Mesh, primitive_uv_sphere_add).
Layout, operator(Mesh, primitive_ico_sphere_add).
Layout, operator(Mesh, primitive_tube_add).
Layout, operator(Mesh, primitive_cone_add).
Layout, separator().
Layout, operator(object, lamp_add).
Layout, separator().
Layout, operator(object, armature_add).
Layout, separator().
Layout, menú(view3d_mt_addm).
Layout, operator(object, parent_set).
Layout, operator(object, editmode_toggle).
Layout, operator(object, delete).
Elif ob, mode == edit_mesh:
#create block.
Layout, operator(create).
Bl_label = create.
Layout, separator().
Layout, menú(info_mt_mesh_add, text=add Mesh, icon=mesh_data).
#transform block.
Layout, operator(transform).
Layout, operator(transform, translate, icon=man_trans).
Layout, operator(transform, rotate, icon=man_rot).
Layout, operator(transform, resize, text=scale, icon=man_scale).
Layout, separator().
#select block.
Layout, operator(selection).
Layout, menú(view3d_mt_edit_mesh_selection_mode, icon=edit).
Layout, menú(view3d_mt_selects, icon=object_datamode).
Layout, separator().
#edit block.
Layout, operator(edit).
Layout, operator(object, editmode_toggle, icon=editmode_hlt).
Layout, menú(view3d_mt_edit_mesh_vértices, icon=vertexsel).
Layout, menú(view3d_mt_edit_mesh_edges, icon=edgesel).
Layout, menú(view3d_mt_edit_mesh_faces, icon=facesel).
Layout, operator(Mesh, lopcut_slide, text=lopcut).
Layout, operator(Mesh, delete, icon=cancel).
Layout, separator().
#tools block.
Layout, operator(tools).
Layout, menú(view3d_mt_edit_mesh_specials, icon=modifier).
Layout, menú(view3d_mt_uv_map, icon=mod_uvproject).
Layout, operator(screen, redo_last, text=tweak last).
#history block.
Layout, operator(history).
Layout, menú(view3d_mt_undos, icon=arrow_leftright).
Class view3d_mt_selects(Bpy, types. Menu):
Bl_label = selections.
Def draw(self, context):
Layout = self, Layout.
Layout, operator_context = invoke_region_win.
Layout, operator(Mesh, select_all).
Layout, operator(Mesh, select_inverse).
Layout, operator(Mesh, select_more).
Layout, operator(Mesh, select_less).
Layout, operator(view3d, select_circle).
Layout, operator(view3d, select_border).
Class view3d_mt_undos(Bpy, types. Menu):
Bl_label = undo/redo.
Def draw(self, context):
Layout = self, Layout.
Layout, operator_context = invoke_region_win.
Layout, operator(ed, undo, icon=tria_left).
Layout, operator(ed, redo, icon=tria_right).
Class view3d_mt_addm(Bpy, types. Menu):
Bl_label = addm.
Def draw(self, context):
Layout = self, Layout.
Layout, operator_context = invoke_region_win.
Layout, operator(Mesh, primitive_plane_add).
Layout, operator(Mesh, primitive_cube_add).
Layout, operator(Mesh, primitive_circle_add).
Layout, operator(Mesh, primitive_uv_sphere_add).
Layout, operator(Mesh, primitive_ico_sphere_add).
Layout, operator(Mesh, primitive_tube_add).
Layout, operator(Mesh, primitive_cone_add).
Def register():
Bpy, types, register(view3d_mt_tols).
Bpy, types, register(view3d_mt_addm).
Bpy, types, register(view3d_mt_selects).
Bpy, types, register(view3d_mt_undos).
Km = Bpy, context, manager, active_keyconfig.keymaps[3d view].
Kmi = km, add_item(wm, call_menu, rightmouse, click).
Kmi, properties, name = view3d_mt_tols.
Def unregister():
Bpy, types, unregister(view3d_mt_tols).
Bpy, types, unregister(view3d_mt_addm).
Bpy, types, unregister(view3d_mt_selects).
Bpy, types, unregister(view3d_mt_undos).
Km = Bpy, context, manager, active_keyconfig.keymaps[3d view].
For kmi in km, items:
If kmi, idname == WM, call_menu:
If kmi, properties, name == view3d_mt_tols:
Km, remove_item(kmi).
Break.
If __name__ == __main__:
Register().
#the menú can then be called anywhere with:
#Layout, menú(view3d_mt_template).
#or you can bind it todo a key by giving the operator WM, call_menu the parameter view3d_mt_template or whaterver you call your menú