0
$\begingroup$

Is there a way to make a custom pie menu in 2.8? I'd like to add one for switching between trackball and turntable navigation. It gets very annoying going into preferences when you just want to use trackball for sculpting and turntable for other things.

$\endgroup$
2
$\begingroup$

there are two ways to add custom pie menus.

  1. get the Pie Menu Editor addon (paid).
  2. code it yourself, its not that difficult, you can use my pie menu addon as a starting point, if have never coded you might want to learn about python first or just copy the code below and put it in a file that ends with .py go to the Add-ons tab and click install, chose the file that you made with the code below.

This is a basic addon that should do the job, the default keymap is Ctrl + D

import bpy
from bpy.types import Menu


bl_info = {
    "name": "S.Simple Pie Menu",
    "author": "Syler",
    "version": (0, 0, 0, 1),
    "description": "Adds Pie Menus",
    "blender": (2, 80, 0),
    "category": "3D view"
}

addon_keymaps = []


def add_hotkey():

    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon

    if not kc:
        print('Keymap Error')
        return
    # object Mode
    km = kc.keymaps.new(name='Object Mode', space_type='EMPTY')
    # here you can chose the keymapping.
    kmi = km.keymap_items.new(
        VIEW3D_OT_PIE_template_call.bl_idname, 'D', 'PRESS', ctrl=True, shift=False)
    addon_keymaps.append((km, kmi))


def remove_hotkey():
    for km, kmi in addon_keymaps:
        km.keymap_items.remove(kmi)

    addon_keymaps.clear()

class VIEW3D_MT_PIE_template(Menu):
    bl_label = 'S.Menu Navigation'
    def draw(self, context):
        print("test")
        layout = self.layout
        prefs = context.preferences
        inputs = prefs.inputs

        pie = layout.menu_pie()
        pie.prop(inputs, "view_rotate_method", expand=True)

class VIEW3D_OT_PIE_template_call(bpy.types.Operator):
    bl_idname = 'sop.sm_template'
    bl_label = 'S.Menu Navigation'
    bl_description = 'Calls pie menu'
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        bpy.ops.wm.call_menu_pie(name="VIEW3D_MT_PIE_template")
        return {'FINISHED'}


def register():
    bpy.utils.register_class(VIEW3D_MT_PIE_template)
    bpy.utils.register_class(VIEW3D_OT_PIE_template_call)
    add_hotkey()

def unregister():
    bpy.utils.unregister_class(VIEW3D_MT_PIE_template)
    bpy.utils.unregister_class(VIEW3D_OT_PIE_template_call)
    remove_hotkey()

if __name__ == "__main__":
    register()

$\endgroup$

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.