Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

June 03, 2015

Custom Pie Menus. easy.

couldn't be any simpler, this includes how to use icons in the EnumProperty - this can reduce the verbosity
import bpy
from bpy.types import Menu
class VIEW3D_PIE_SV_ops(bpy.types.Operator):
bl_idname = "nodes.pie_menu_enum"
bl_label = "Add Quick Node"
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):
print('added ', self.selected_mode)
return {'FINISHED'}
class VIEW3D_PIE_template(Menu):
# label is displayed at the center of the pie menu.
bl_label = "Select Mode"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
pie.operator_enum("nodes.pie_menu_enum", "selected_mode")
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
bpy.ops.wm.call_menu_pie(name="VIEW3D_PIE_template")