Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created January 20, 2016 23:21
Show Gist options
  • Save zeffii/d7831aabe115dd55216d to your computer and use it in GitHub Desktop.
Save zeffii/d7831aabe115dd55216d to your computer and use it in GitHub Desktop.
import bpy
class Rotator(bpy.types.Operator):
bl_idname = "pieops.set_manip"
bl_label = "Set the manip"
def execute(self, context):
try:
context.space_data.transform_manipulators = {'ROTATE'}
except:
print('failed to set')
return {'FINISHED'}
class NewPie(bpy.types.Menu):
bl_idname = 'kwanza'
bl_label = "Select Mode"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
pie.operator("mesh.primitive_cube_add")
pie.operator("pieops.set_manip", text="ROTATE")
addon_keymaps = []
def register():
bpy.utils.register_class(Rotator)
bpy.utils.register_class(NewPie)
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
km = kc.keymaps.new('3D View', space_type='VIEW_3D', region_type='WINDOW')
keymaps = km.keymap_items
new_shortcut = keymaps.new("wm.call_menu_pie", "SEMI_COLON", "PRESS", shift=True)
new_shortcut.properties.name = 'kwanza'
addon_keymaps.append((km, new_shortcut))
def unregister():
bpy.utils.unregister_class(Rotator)
bpy.utils.unregister_class(NewPie)
for km, shortcut in addon_keymaps:
km.keymap_items.remove(shortcut)
addon_keymaps.clear()
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment