I’m trying to get toolbar items to be repurposed for custom pie menus. Currently, there’s no clear way to do this, except to rebuild the tools’ access (such as: Move, Rotate, Scale, etc.) from scratch using the builtin GIZMO_GT primitives.
Edit: After a lot of trial and error and re-purposing of bits of code by other devs and artists, I cobbled together the following:
import bpy
from bpy.types import (
GizmoGroup,
Operator
)
class VIEW3D_OT_gizmo_translate(Operator):
"""Show Translate Gizmo"""
bl_idname = "view3d.gizmo_translate"
bl_label = "gizmo translate"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
areas = context.workspace.screens[0].areas
for area in areas:
for space in area.spaces:
if space.type == 'VIEW_3D':
space.show_gizmo_object_translate^= True
if space.show_gizmo== False:
space.show_gizmo= True
if space.show_gizmo_context== False:
space.show_gizmo_context= True
if space.show_gizmo_tool== False:
space.show_gizmo_tool= True
return{'FINISHED'}
From what I can gather, however, this toggles the transform gizmos, as in the pop-over method (in fact, you can see the Move checkbox checked in the Show Gizmo pop-over, when you invoke this code). Again, it’s a toggle, so execute once, it comes on; execute again, it turns off.
What I’m after is the exact behaviour of the tools from the toolbar. By looking at the toolbar’s code, however, I can’t see any definitive signs that point to how that’s done. Again, what I’m looking to do is mimic the exact behaviour of the transform gizmo tools from the toolbar, in a custom pie menu. Is this even possible using Blender Python’s API?
The other question is how do I get the icon names of the NEW TOOLBAR ICONS? Currently, there’s no obvious way of finding out how to use them in a pie menu, such as the following:
import bpy
from bpy.types import Menu
class VIEW3D_MT_PIE_template(Menu):
bl_label = "Transform Tools"
def draw(self, context):
layout = self.layout
row = layout.row()
pie = layout.menu_pie()
pie.operator("view3d.gizmo_translate", text="Translate", icon='GIZMO')
pie.operator("view3d.gizmo_rotate", text="Rotate", icon='PHYSICS')
pie.operator("view3d.gizmo_scale", text="Scale", icon='MOD_MESHDEFORM')
Guidance would be appreciated.