# Can the mesh select mode menu converted to a pie menu in Blender 2.72?

The release notes mention that it is possible to add pie menus. But I'm not sure how to do it.

How could I convert the mesh select mode menu's appearance:

to this?

Some Basics are documented in the Blender Wiki, see:

Below you find a complete, briefly commented and fully working mini example addon. Just place the code below into a file named

whatever_name_you_like.py


and then Install/Enable this python file as a regular Addon.

Notes:

• The name of the file is not important, however the appendix '.py' is essential to mark this as a python file.
• You do not need to enable the "Pie Menus Official" Addon in order to get your own Pie menus to work properly!

## Begin of the code:

bl_info = {
"name": "My Pies",
"author": "My Name",
"version": (1, 1, 0),
"blender": (2, 72, 0),
"category": "Object" }

import bpy

# Implements an edit mode selection pie

# label is displayed at the center of the pie menu.
bl_label  = "Select Mode" # Appears as Pie title
bl_idname = "mesh.mypie"  # Used to refer (see below)

def draw(self, context):
layout = self.layout

# operator_enum will just spread all available options
# for the type enum of the operator on the pie
pie.operator_enum("mesh.select_mode", "type")

addon_keymaps = [] # Store keymaps to use in unregister()

def register():
bpy.utils.register_class(VIEW3D_PIE_template)

# Define a keyboard shortcut (for Mesh Edit mode)
wm = bpy.context.window_manager

# Open the pie when you press CTRL SHIFT E:
kmi = km.keymap_items.new("wm.call_menu_pie", 'E', 'PRESS', shift=True, ctrl=True)
kmi.properties.name="mesh.mypie"

def unregister():
bpy.utils.unregister_class(VIEW3D_PIE_template)

#use stored keymaps to unregister
km.keymap_items.remove(kmi)

if __name__ == "__main__":
register()


Try this video: http://vimeo.com/103321600 The actual tutorial starts at about two minutes. Hope that helps! :)

By chance the video describes exactly how to create the mesh select mode as pie.menu. With the pie-menus a new python script template has been added, it is accessible from the text editor:

• While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – David Sep 20 '14 at 14:51
• Thank you, I will keep that in mind. In this case though, I thought that it would be too complicated to explain in a text answer and would be better to link to the video. – Code Cube Sep 20 '14 at 15:26

I know this has being answered correctly by Gaia Clary , but I needed to do a similar thing, and it took me a little while to find the exact code needed, so here it is. I wanted to be able to pick some (but not all of the mesh select menus).The code below shows how I achieved this.

    bl_info = {
"author": "Oluwayomi Longe",
"version": (0, 0, 1),
"blender": (2, 73),
"category": "3D View",}

import bpy

# Pie Select Mode - Tab
bl_idname = "pie.tabmode"
bl_label = "Select Mode"

def draw(self, context):
layout = self.layout

#4 - LEFT
# use the commented line below if you want to toggle Edit and object mode
#pie.operator("object.editmode_toggle", text="Edit/Object", icon='OBJECT_DATAMODE')

pie.operator("object.mode_set", text="Edit", icon='EDITMODE_HLT').mode='EDIT'
#6 - RIGHT
pie.operator("object.mode_set", text="Object", icon='OBJECT_DATAMODE').mode='OBJECT'

#3 - BOTTOM
box = pie.split().column()
row = box.row(align=True)
box.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
box.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
box.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
#8 - TOP
#pie.operator("sculpt.sculptmode_toggle", text="Sculpt", icon='SCULPTMODE_HLT')
pie.operator("object.mode_set", text="Sculpt", icon='SCULPTMODE_HLT').mode='SCULPT'

def register():
bpy.utils.register_class(PieTabMode)
# or any other classes you add

wm = bpy.context.window_manager

#Select Mode
kmi.properties.name = "pie.tabmode"

def unregister():
bpy.utils.unregister_class(PieTabMode)
# or any other classes you add

km.keymap_items.remove(kmi)

if __name__ == "__main__":
register()


And here another, using the icon field of the bpy.types.EnumProperty(). I think the template provided now in TextEditor is a little sparse, this might help.

import bpy

class VIEW3D_PIE_SV_ops(bpy.types.Operator):

mode_options = [
("option1", "option1", "", "CURVE_DATA", 0),
("option2", "option2", "", "", 1),
("option3", "option3", "", "", 2)
]

selected_mode = bpy.props.EnumProperty(
items=mode_options,
description="offers....",
default="option1"
)

def execute(self, context):
return {'FINISHED'}

# label is displayed at the center of the pie menu.
bl_label = "Select Mode"

def draw(self, context):
layout = self.layout

def register():
bpy.utils.register_module(__name__)

def unregister():
bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
register()



Just find it, and I think i have a nice code from my project for it.

I wrote also one for bone selection and one for selection in object mode

# Pie Selection Edit Mode
bl_idname = "pie.selectionsem"
bl_label = "Pie Selections Edit Mode"

def draw(self, context):
layout = self.layout
# 4 - LEFT
pie.operator("view3d.select_border", text="Border Select",
icon='BORDER_RECT')
# 6 - RIGHT
# 2 - BOTTOM
box = pie.split().column()
row = box.row(align=True)
row.operator("mesh.select_less", text="Select LESS", icon='DISCLOSURE_TRI_DOWN')
row.operator("mesh.select_more", text="Select MORE", icon='DISCLOSURE_TRI_RIGHT')
box.operator("mesh.select_nth", text="Checker DESelect", icon='DOTSDOWN')

# 8 - TOP
pie.operator("mesh.select_all", text="Select All/None",
icon='RESTRICT_SELECT_OFF').action = 'TOGGLE'
# 7 - TOP - LEFT
#pie.operator("mesh.select_all", text="Select All Toggle",
#            icon='ARROW_LEFTRIGHT').action = 'TOGGLE'

# 9 - TOP - RIGHT
pie.operator("mesh.select_all", text="Invert Selection",
icon='FULLSCREEN_EXIT').action = 'INVERT'
# 1 - BOTTOM - LEFT
pie.operator("view3d.select_circle", text="Circle Select",
icon='BORDER_LASSO')
# 3 - BOTTOM - RIGHT

box = pie.split().column()
row = box.row(align=True)
row.operator("mesh.select_mode", text="Select Vertex", icon='VERTEXSEL').type='VERT'
row.operator("mesh.select_mode", text="Select Edge", icon='EDGESEL').type='EDGE'
row = box.row(align=True)
row.operator("mesh.select_mode", text="Select Face", icon='FACESEL').type='FACE'
prop = row.operator("wm.context_set_value",
text="V&E&F Select",
icon='OBJECT_DATA')
prop.value = "(True, True, True)"
prop.data_path = "tool_settings.mesh_select_mode"