I have the following code which is a modified version of the template for new pie menus however it doesn't function properly.

pie.operator("transform.select_orientation", text="Local").orientation='LOCAL'

should change the orientation to Local. However it doesn't, it opens a menu instead. Why is this?

import bpy
from bpy.types import Menu

# spawn an edit mode selection pie (run while object is in edit mode to get a valid output)

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("transform.select_orientation", text="Global").orientation='GLOBAL'
        pie.operator("transform.select_orientation", text="Local").orientation='LOCAL'
addon_keymaps = []
def register():
    wm = bpy.context.window_manager

    if wm.keyconfigs.addon:
        km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal')
        kmi = km.keymap_items.new('wm.call_menu_pie', 'D', 'PRESS', ctrl=True,)

def unregister():

    wm = bpy.context.window_manager

    if wm.keyconfigs.addon:
        for km in addon_keymaps:
            for kmi in km.keymap_items:


    # clear the list
    del addon_keymaps[:]

if __name__ == "__main__":

The invoke method of the operator is called which shows the menu.

You might set the operator's context using UILayout.operator_context to EXEC_DEFAULT to directly call the operators execute method with the argument given:

pie.operator_context = 'EXEC_DEFAULT'
pie.operator("transform.select_orientation", text="Local").orientation='LOCAL'

You can also use the generic wm.context_set_enum operator to change the transform orientation:

op_props = pie.operator("wm.context_set_enum")
op_props.data_path = "space_data.transform_orientation"
op_props.value = 'LOCAL'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.