# Custom Pie Menu B3D 2.72b

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

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

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

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

pie.operator("transform.select_orientation", text="Global").orientation='GLOBAL'
pie.operator("transform.select_orientation", text="Local").orientation='LOCAL'
def register():
bpy.utils.register_class(VIEW3D_PIE_template)
wm = bpy.context.window_manager

kmi = km.keymap_items.new('wm.call_menu_pie', 'D', 'PRESS', ctrl=True,)

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

wm = bpy.context.window_manager

for kmi in km.keymap_items:
km.keymap_items.remove(kmi)

# clear the list

if __name__ == "__main__":
register()


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'