-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
apiAPI changes or additionsAPI changes or additionsenhancementNew feature or requestNew feature or request
Milestone
Description
Summary
Improve dynamically generated macro operators to support:
- User-defined
bl_descriptionfor proper tooltips - Argument-free invocation (auto-build from pmi)
Background
Current Problem
When registering a PME macro to standard Blender UI (toolbar, menu, etc.):
Option 1: Via pme_user_pie_menu_call
layout.operator("wm.pme_user_pie_menu_call", text="My Macro").pie_menu_name = "My Macro"
# Tooltip: "Call PME menu" ← Generic, not helpfulOption 2: Direct macro operator
bpy.ops.pme.macro_my_macro(
MESH_OT_primitive_cube_add={"size": 2, ...},
PME_OT_macro_exec1={"cmd": "bpy.ops.transform.translate()"},
# ... all arguments required!
)
# Tooltip: (undocumented operator) ← No bl_description setDesired Behavior
# Argument-free invocation
bpy.ops.pme.macro_my_macro() # Auto-builds args from pmi internally
# Proper tooltip when registered to UI
layout.operator("pme.macro_my_macro")
# Tooltip: "Add cube and transform" ← User-defined description!Proposed Changes
1. Add description property to PMItem
File: pme_types.py (around line 359)
description: StringProperty(
name="Description",
description="Description shown in tooltips when registered to Blender UI",
default="",
maxlen=CC.MAX_STR_LEN,
)2. Set bl_description in macro generation
File: infra/macro.py - add_macro() function
defs = {
"bl_label": pm.name,
"bl_idname": tp_bl_idname,
"bl_options": {'REGISTER', 'UNDO'},
}
# NEW: Set bl_description from pm.description
if hasattr(pm, 'description') and pm.description:
defs["bl_description"] = pm.description3. Support argument-free invocation
Option A: Modify dynamic macro's invoke() to auto-fill props
Option B: Expose execute_macro(pm) via API
# api/dynamic.py
def call_macro(name: str) -> set[str]:
"""Call macro by name (auto-builds args from pmi)"""
from ..infra.macro import execute_macro
pm = get_prefs().pie_menus.get(name)
return execute_macro(pm) if pm else {'CANCELLED'}Note: execute_macro() already exists in infra/macro.py:238-273 and uses _fill_props() to auto-build arguments from pmi.
JSON Schema v2 Integration
{
"uid": "mc_9f7c2k3h",
"name": "My Macro",
"type": "MACRO",
"description": "Add cube and transform",
"items": [...]
}The description field maps to bl_description for macro operators.
Benefits
| Before | After |
|---|---|
| Generic "Call PME menu" tooltip | User-defined description |
| "Undocumented operator" warning | Proper operator info |
| All arguments required | Argument-free invocation possible |
| Hard to use in external scripts | pme.call_macro("name") API |
Related Issues
- PME2: GPU-rendered description tooltip for Pie Menu #100 - GPU-rendered description tooltip for Pie Menu (PME internal tooltips)
- PME2: description / description_expr implementation #81 - description/description_expr implementation (JSON schema)
This issue focuses on Blender UI integration (external tooltips), while #100 focuses on PME internal tooltip rendering.
Implementation Notes
execute_macro()already handles pmi → props conversion- Minimal changes to
add_macro()for bl_description - API exposure is optional but recommended for external scripting
Metadata
Metadata
Assignees
Labels
apiAPI changes or additionsAPI changes or additionsenhancementNew feature or requestNew feature or request