1
$\begingroup$

I'm trying to make a pie menu for select mode in the Edit Mode and UV Editor, it's a pie to select vertex, edges, faces and in the UV Editor there is also Island.

The operator for the select mode in Edit mode worked, but I couldn't find the operator on the UV Editor. Here is what I got so far.

 import bpy
from bpy.types import Menu

# Spawn a pie menu for select mode in Edit Mode in the 3D View


class EDIT_SELECT_MODE(Menu):
    # label is displayed at the center of the pie menu.
    bl_label = "Edit Select Mode"
    bl_idname = "pie.edit_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")

# Spawn a pie menu for select mode in UV Editor 

class UV_SELECT_MODE(Menu):
    bl_label = "UV Select Mode"
    bl_idname = "pie.uv_select_mode"

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


        tool_settings = context.tool_settings
        pie = layout.menu_pie()

        # Do smart things depending on whether uv_select_sync is on.

        if tool_settings.use_uv_select_sync:
            op = pie.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
            op.value = "(True, False, False)"
            op.data_path = "tool_settings.mesh_select_mode"

            op = pie.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
            op.value = "(False, True, False)"
            op.data_path = "tool_settings.mesh_select_mode"

            op = pie.operator("wm.context_set_value", text="Face", icon='FACESEL')
            op.value = "(False, False, True)"
            op.data_path = "tool_settings.mesh_select_mode"            

        else:
            op = pie.operator("wm.context_set_string", text="Vertex", icon='UV_VERTEXSEL')
            op.value = 'VERTEX'
            op.data_path = "tool_settings.uv_select_mode"

            op = pie.operator("wm.context_set_string", text="Edge", icon='UV_EDGESEL')
            op.value = 'EDGE'
            op.data_path = "tool_settings.uv_select_mode"

            op = pie.operator("wm.context_set_string", text="Face", icon='UV_FACESEL')
            op.value = 'FACE'
            op.data_path = "tool_settings.uv_select_mode"

            op = pie.operator("wm.context_set_string", text="Island", icon='UV_ISLANDSEL')
            op.value = 'ISLAND'
            op.data_path = "tool_settings.uv_select_mode"


classes = (
EDIT_SELECT_MODE,
UV_SELECT_MODE,
)

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

    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name="Mesh")
    kmi = km.keymap_items.new("wm.call_menu_pie", "SPACE", "PRESS").properties.name="pie.edit_select_mode"     

    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name="UV Editor")
    kmi = km.keymap_items.new("wm.call_menu_pie", "SPACE", "PRESS").properties.name="pie.uv_select_mode"  


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

if __name__ == "__main__":
    register()
$\endgroup$
  • $\begingroup$ Do you need it in the 3d view as well? So it needs to be two pie menus, one if over the 3d view and another for the UV editor, and needs to give you all the options for each, both called from the same key press? $\endgroup$ – Craig D Jones Oct 28 at 17:19
  • $\begingroup$ Yes, two pie menus. One for select mode in Edit Mode in the 3D view and another for select mode in UV Editor. I posted a new code, that the pie menu works on both, but it didn't inclued the Island element in the UV Editor pie. $\endgroup$ – Lucas Falcão Oct 28 at 22:57
  • $\begingroup$ It looks like the only one working is the 3d view, the other isn't actually working. I am looking at this one to see if I can just adapt to 2.8 to see why the other doesn't work blenderartists.org/t/uv-pie-menu-rmb/640066 $\endgroup$ – Craig D Jones Oct 29 at 1:10
  • $\begingroup$ Thank you Craig! $\endgroup$ – Lucas Falcão Oct 30 at 2:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.