Struggling to create a Maya pie menu- need help


Hi. I’m completely new to Blender coding, and I wish to create a Maya-like pie menu, oppened on LMB click.

Firstly, I oppened the pie menu template, which seems the best way to start.


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()
        # operator_enum will just spread all available options
        # for the type enum of the operator on the pie
        pie.operator_enum("mesh.select_mode", "type")


def register():
    bpy.utils.register_class(VIEW3D_PIE_template)


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


if __name__ == "__main__":
    register()

    bpy.ops.wm.call_menu_pie(name="VIEW3D_PIE_template")

  

I have some question:

  1. How do I assign LMB to open that particular pie menu ?

  2. How do I change the menu items location? When I spawn the pie, the edge vertex and face is not in the same order as in the image. By using this line " pie.operator_enum(“mesh.select_mode”, “type”) , it seems that the order is random. Is it possible to put separate operators for edges select, vertex select and face select in slots similar to the pie in Maya ?

  3. Wish to assign to the pie vertex-face and multi.

    In docs, found this thing, but don’t get it how to make it work:

bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type=‘VERT’, action=‘TOGGLE’)
Change selection mode

Parameters:
use_extend (boolean, (optional)) – Extend
use_expand (boolean, (optional)) – Expand
type (enum in [‘VERT’, ‘EDGE’, ‘FACE’], (optional)) – Type
action (enum in [‘DISABLE’, ‘ENABLE’, ‘TOGGLE’], (optional)) –
Action, Selection action to execute
DISABLE Disable, Disable selected markers.
ENABLE Enable, Enable selected markers.
TOGGLE Toggle, Toggle disabled flag for selected markers.
bpy.ops.mesh.select_more(use_face_step=True)
Select more vertices, edges or faces connected to initial selection

  1. How to assign object.mode_set to the pie ?