パイメニュー

ドキュメント:

bpy.types.UILayout.menu_pie | Blender Python API [Official]

使い方

参考:

オリジナルのマーキングメニューを作成する方法 | Harkerblog

Permanently expanded submenu in pie menu – Blender Artists Community

Is there a way to add a custom pie menu in 2.8? – Blender Stack Exchange

How to properly overwrite default keys with pie menu hotkeys – Blender Stack Exchange

Make a Pie-Specials Menu, dependent on selection type – Blender Stack Exchange

shift in my hotkeys toggles multi-selection mode between vertex edge and faces, how to toggle off previous mode? – Blender Stack Exchange

Can the mesh select mode menu converted to a pie menu in Blender 2.72? – Blender Stack Exchange

How would one code a pie menu with an additional traditional menu beneath it? – Blender Stack Exchange

空き項目

空き項目にする場合は、pie.separator() を呼ぶ。

参考:

bpy.types.UILayout.separator | Blender Python API [Official]

Pie Menus with custom positions – Blender Stack Exchange

項目の順序

  • 左 (4)
  • 右 (6)
  • 下 (2)
  • 上 (8)
  • 左上 (7)
  • 右上 (9)
  • 左下 (1)
  • 右下 (3)

パイメニューでモードを切り替える

コードサンプル
import bpy
from bpy.props import StringProperty
from bpy.types import Menu

mode_text = {
    'OBJECT': "Object Mode",
    'EDIT': "Edit Mode",
    'SCULPT': "Sculpt Mode",
    'VERTEX_PAINT': "Vertex Paint",
    'WEIGHT_PAINT': "Weight Paint",
    'TEXTURE_PAINT': "Texture Paint",
    'PARTICLE_EDIT': "Particle Edit",
    'PAINT_GPENCIL': "Draw Mode",
}

class MYTOOL_OT_mode_set(bpy.types.Operator):
    bl_idname = 'mytool.mode_set'
    bl_label = "Set Object Mode"

    mode: StringProperty()

    @classmethod
    def description(cls, context, props):
        mode = getattr(props, 'mode', None)
        text = mode_text.get(mode, None)
        if text:
            return f"Switch to {text}"
        return super().description(context, props)

    def execute(self, context):
        bpy.ops.object.mode_set(mode=self.mode)
        return {'FINISHED'}

edit_mode = {
    'MESH': 'EDIT_MESH',
    'CURVE': 'EDIT_CURVE',
    'SURFACE': 'EDIT_SURFACE',
    'FONT': 'EDIT_TEXT',
    'ARMATURE': 'EDIT_ARMATURE',
    'META': 'EDIT_METABALL',
    'LATTICE': 'EDIT_LATTICE',
    'GPENCIL': 'EDIT_GPENCIL',
}

class MYTOOL_MT_pie_modes(Menu):
    bl_label = "Pie Modes"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

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

        if context.active_object is None:
            return

        pie = layout.menu_pie()
        active = context.active_object

        # 4 - Left
        if context.mode != 'OBJECT':
            pie.operator('mytool.mode_set', text="Object Mode"
                ).mode = 'OBJECT'
        else:
            row = pie.row()
            row.enabled = False
            row.operator('mytool.mode_set', text="Object Mode"
                ).mode = 'OBJECT'

        # 6 - Right
        if (active.type in edit_mode
                and context.mode != edit_mode.get(active.type)):
            if active.type == 'GPENCIL':
                pie.operator('mytool.mode_set', text="Edit Mode"
                    ).mode = 'EDIT_GPENCIL'
            else:
                pie.operator('mytool.mode_set', text="Edit Mode"
                    ).mode = 'EDIT'
        else:
            row = pie.row()
            row.enabled = False
            row.operator('mytool.mode_set', text="Edit Mode"
                ).mode = 'EDIT'

        # 2 - Bottom
        if active.type == 'MESH' and context.mode != 'SCULPT':
            pie.operator('mytool.mode_set', text="Sculpt Mode"
                ).mode = 'SCULPT'
        else:
            row = pie.row()
            row.enabled = False
            row.operator('mytool.mode_set', text="Sculpt Mode"
                ).mode = 'SCULPT'

        # 8 - Top
        if active.type == 'MESH' and context.mode != 'PAINT_VERTEX':
            pie.operator('mytool.mode_set', text="Vertex Paint"
                ).mode = 'VERTEX_PAINT'
        else:
            row = pie.row()
            row.enabled = False
            row.operator('mytool.mode_set', text="Vertex Paint"
                ).mode = 'VERTEX_PAINT'

        # 7 - Top Left
        if active.type == 'MESH' and context.mode != 'PAINT_WEIGHT':
            pie.operator('mytool.mode_set', text="Weight Paint"
                ).mode = 'WEIGHT_PAINT'
        else:
            row = pie.row()
            row.enabled = False
            row.operator('mytool.mode_set', text="Weight Paint"
                ).mode = 'WEIGHT_PAINT'

        # 9 - Top Right
        if active.type == 'MESH' and context.mode != 'PAINT_TEXTURE':
            pie.operator('mytool.mode_set', text="Texture Paint"
                ).mode = 'TEXTURE_PAINT'
        else:
            row = pie.row()
            row.enabled = False
            row.operator('mytool.mode_set', text="Texture Paint"
                ).mode = 'TEXTURE_PAINT'

        # 1 - Bottom Left
        if (active.type == 'MESH'
                and active.particle_systems and context.mode != 'PARTICLE'):
            pie.operator('mytool.mode_set', text="Particle Edit"
                ).mode = 'PARTICLE_EDIT'
        else:
            row = pie.row()
            row.enabled = False
            row.operator('mytool.mode_set', text="Particle Edit"
                ).mode = 'PARTICLE_EDIT'

        # 3 - Bottom Right
        if active.type == 'GPENCIL' and context.mode != 'PAINT_GPENCIL':
            pie.operator('mytool.mode_set', text="Draw Mode"
                ).mode = 'PAINT_GPENCIL'
        else:
            row = pie.row()
            row.enabled = False
            row.operator('mytool.mode_set', text="Draw Mode"
                ).mode = 'PAINT_GPENCIL'

classes = [
    MYTOOL_OT_mode_set,
    MYTOOL_MT_pie_modes,
]

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

def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)Code language: Python (python)

参考:

Mesh / Object Mode with pie menu? – Blender Stack Exchange

設定を切り替える

参考:

How can I add a Keymap and Pie Menu shortcut for Auto Depth toggle? – Blender Stack Exchange

Can I assign a toggle shortcut to the Cursor Depth feature in User Preferences? – Blender Stack Exchange

特殊なレイアウトを作成する

参考:

permanently expanded submenu in pie menu – Blender Artists Community

チュートリアル

Make Your Own Custom Pie Menu Addon (Blender Bash)

How to Create Custom Pie Menus (CG Life)

Create Your Own Pie Menu (Blender Stuffs)

Exploring the Pie Menu Template (CG Python)

Extending Pie Menus with Custom Operators (CG Python)

Pie Menu Editor

動画:

Review (Steven Scott)

How to Use (r3a1ay)

Review (r3a1ay)

How to Use (Game Dev Fred)

入手:

Pie Menu Editor | Gumroad

Pie Menu Editor | Blender Market

フォーラム:

Pie Menu Editor | Blender Artists Community

参考:

Pie Menu Editor – 痒いところに手が届く作業効率 Upアドオン! | CGbox

視聴:

Pie Menu Editor (r3a1ay) – YouTube

記事をシェアする:
タグ:

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

Protected by reCAPTCHA