3
$\begingroup$

Normally when you make your own pie menu the position of the buttons, whether they are on the east, west or whatever position is defined by the order you call them in the draw function.

import bpy
from bpy.types import Menu, Operator

addon_keymaps = []


class MT_3DCursor(Menu):
    # bl_label is displayed at the center of the pie menu
    bl_label = '3D Cursor Actions'
    bl_idname = 'MT_3DCursor'


    def draw(self, context):
        layout = self.layout
        pie = layout.menu_pie()
        # Here should be every function for the pie menu
        # Order the lines in different order for different pie order
        # Pie order: west, east, south, north, north-west, north-east, south-west, south-east
        pie.operator('view3d.snap_cursor_to_selected', icon = 'EVENT_A')
        pie.operator('view3d.snap_cursor_to_selected', icon = 'EVENT_B')
        pie.operator('view3d.snap_cursor_to_selected', icon = 'EVENT_C')
        pie.operator('view3d.snap_cursor_to_selected', icon = 'EVENT_D')
        pie.operator('view3d.snap_cursor_to_selected', icon = 'EVENT_E')
        pie.operator('view3d.snap_cursor_to_selected', icon = 'EVENT_F')
        pie.operator('view3d.snap_cursor_to_selected', icon = 'EVENT_G')
        pie.operator('view3d.snap_cursor_to_selected', icon = 'EVENT_H')



class OT_snapCursorToSelected(Operator):
    #needs to be lower case and underscores as word separation
    bl_idname = 'view3d.snap_cursor_to_selected'
    bl_label = 'Snap Cursor to Selected'
    bl_description = 'Snap the 3D Cursor to middle of selected item(s)'

    def execute(self, context):
        # the commands of the functions you want to use
        bpy.ops.view3d.snap_cursor_to_selected()
        return {'FINISHED'}


classes = (MT_3DCursor,
           OT_snapCursorToSelected,
           )


def register():
    for cls in classes:
        bpy.utils.register_class(cls)


def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)


if __name__ == '__main__':
    register()
    bpy.ops.wm.call_menu_pie(name = 'MT_3DCursor')

But I saw someone having a pie menu having a button only at the north and south position, so you can somehow say where the button should be positioned.

The standard order is like this, west, east, south, north, north-west, north-east, south-west, south-east:

enter image description here

$\endgroup$
0

1 Answer 1

1
$\begingroup$

Pie menus are arranged in the order West, East, South, North, Northwest, Northeast Southwest Southeast; as you said. If you have more than 8 entries, the cycle repeats, causing entries to lie on top of each other.

To skip an entry, insert a separator() layout element. Since you want North and South with two item, something like this fragment works:

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

        pie.separator() # Skip West position
        pie.separator() # Skip East position
        pie.operator("my.align", text="World", icon = "WORLD").alignment = "WORLD"
        pie.operator("my.align", text="View", icon = "VIEW3D").alignment = "VIEW"

This gives an example menu of

Pie menu with two entries

Note that the numeric shortcuts remain the same. North is still '8' and South is still '2'. That's because the match the numpad layout.

$\endgroup$
1
  • 1
    $\begingroup$ Great tip, that the number shortcuts matches the numpad layout! $\endgroup$
    – Lala_Ghost
    Commented Jan 17, 2022 at 7:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .