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():
bpy.utils.register_class(VIEW3D_PIE_template)
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,)
addon_keymaps.append(km)
def unregister():
bpy.utils.unregister_class(VIEW3D_PIE_template)
wm = bpy.context.window_manager
if wm.keyconfigs.addon:
for km in addon_keymaps:
for kmi in km.keymap_items:
km.keymap_items.remove(kmi)
wm.keyconfigs.addon.keymaps.remove(km)
# clear the list
del addon_keymaps[:]
if __name__ == "__main__":
register()
bpy.ops.wm.call_menu_pie(name="VIEW3D_PIE_template")