Post #502: ![](https://blenderartists.org/user_avatar/blenderartists.org/roaoao/48/37600_2.

📋 Metadata

🏷️ Tags

pie-menu hotkeys intermediate unsolved

  • Pie Menu Editor
  • Stack Key Editor
  • Python Scripting

💬 Content

roaoao:

Here is an example.

def main():
    obj = C.selected_objects and C.active_object
    if not obj:
        open_menu("None Object")

    elif obj.type == "MESH":
        if obj.mode == 'EDIT':
            msm = C.tool_settings.mesh_select_mode
            msm[0] and open_menu("Vertex") or \
                msm[1] and open_menu("Edge") or \
                msm[2] and open_menu("Face") or \
                open_menu("Edit") or \
                open_menu("Mesh") or \
                open_menu("Any Object")

        else:
            open_menu(obj.mode.replace("_", " ").title()) or \
                open_menu("Mesh") or \
                open_menu("Any Object")

    else:
        open_menu(obj.mode.replace("_", " ").title()) or \
            open_menu(obj.type.replace("_", " ").title()) or \
            open_menu("Any Object")

main()

Save it as command_context_sensitive.py in pie_menu_editor/scripts folder. And use it in Command tab:

execute_script("scripts/command_context_sensitive_menu.py")

This script tries to find a menu by name and open it in this order:

None Object(if nothing is selected),
Vertex, Edge, Face,
(mesh edit mode)**,
Object, Edit, Pose, Sculpt, Vertex Paint, Weight Paint, Texture Paint, Particle Edit, Gpencil Edit, **
**Mesh, Curve, Surface, Meta, Font, Armature, Lattice, Empty, Camera, Lamp, Speaker,
Any Object
**

Thanks, however I can only get this to work with Object Menu… I’ve got it set to open with a Stack Key and added a few blank pies (named Armature, Lamp, Curve, None object), but only the Object Pie shows up.


🔗 View on Blender Artists