Skip to main content
4 of 4
added 1951 characters in body
Gaia Clary
  • 3.8k
  • 2
  • 27
  • 40

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),
    "description": "My Pie menu",
    "category": "Object" }

import bpy
from bpy.types import Menu

# Implements an edit mode selection pie

class VIEW3D_PIE_template(Menu):
    # 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

        pie = layout.menu_pie()
        # 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
    km = wm.keyconfigs.addon.keymaps.new(name="Mesh")
    
    # 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"
    addon_keymaps.append((km,kmi)) # Store keymap


def unregister():
    bpy.utils.unregister_class(VIEW3D_PIE_template)
    
    #use stored keymaps to unregister
    for km, kmi in addon_keymaps:
        km.keymap_items.remove(kmi)
    addon_keymaps.clear()

if __name__ == "__main__":
    register()
Gaia Clary
  • 3.8k
  • 2
  • 27
  • 40