Python API
Use the public bpy.ops.wm.ih_menu_weave_* operators from Blender Python. They do not require importing the extension’s installation-specific package. Calls return Blender status sets; reported errors may surface as RuntimeError through bpy.ops.
API at a glance
Section titled “API at a glance”Click a card to read its contract. Code blocks support native selection and copying. Calls that depend on the executing menu action are identified below.
Repeat
- Repeat Last Actionbpy.ops.wm.ih_menu_weave_repeat_last_action()
Repeat the latest compatible Blender operation or successful menu action.
- Set Repeat Codebpy.ops.wm.ih_menu_weave_set_repeat_code(code="bpy.ops.mesh.select_all(action='SELECT')")
Store a self-contained repeat script on the owning menu action; this example requires Mesh Edit Mode when repeated.
Global shortcuts
- Toggle Global Hotkeysbpy.ops.wm.ih_menu_weave_toggle_global_hotkeys()
Toggle the executing action’s root-menu priority, or pass an explicit root menu ID.
- Disable All Global Hotkeysbpy.ops.wm.ih_menu_weave_clear_global_hotkeys()
Disable Global Priority on every root menu without modifying native keymaps.
Temporary visibility
- Toggle Hidden Actionsbpy.ops.wm.ih_menu_weave_toggle_show_hidden_actions()
Temporarily reveal hidden Python actions or restore their saved visibility.
- Toggle Hidden Foldersbpy.ops.wm.ih_menu_weave_toggle_show_hidden_menus()
Temporarily reveal hidden folders independently from hidden actions.
Script execution context
Section titled “Script execution context”An action receives bpy, context, ih_menu_weave, and __name__ = "__main__". Each run gets a fresh namespace. Explicit import bpy makes examples easier to reuse outside MenuWeave.
import bpy
obj = bpy.context.active_objectif obj is None or bpy.context.mode != 'OBJECT': raise RuntimeError("Select an object in Object Mode")obj.location.x += 1.0Configure menu filters and still check prerequisites in the script. A repeat may run with another selection or mode. For context-sensitive bpy.ops calls, check poll() and use a suitable context.temp_override(...) when needed. EXEC_DEFAULT executes immediately; INVOKE_DEFAULT may start a dialog or modal interaction.
Scripts have the permissions of the current Blender session. An exception prevents repeat-history registration but does not automatically undo data changes already made by the script.
Repeat last action
Section titled “Repeat last action”bpy.ops.wm.ih_menu_weave_repeat_last_action()Repeats Blender’s latest compatible repeatable operation, including a successful MenuWeave Python action. Native Shift+R uses the same history. A newer native operation takes precedence over an older menu action, including one with custom repeat code.
Inside a menu script, the injected repeat_last_action() helper is also available. A repeat request from a menu script is deferred until that script operator returns, outside its Undo scope; it is not executed immediately in the middle of the script. Repeat uses no background polling or timers.
Use this call alone for a Repeat action. Do not call Repeat Last from custom repeat code: recursive repetition is rejected. The current editor, mode, selection, and referenced resources must support the repeated operation.
Set repeat code
Section titled “Set repeat code”import bpy
obj = bpy.context.active_objectif obj is None or bpy.context.mode != 'OBJECT': raise RuntimeError("Select an object in Object Mode")
obj.location.x += 1.0bpy.ops.wm.ih_menu_weave_set_repeat_code( code="bpy.context.active_object.location.x += 1.0")code is a non-empty, syntactically valid Python string. It is stored for subsequent repeats, not executed when set. Include all imports, definitions, and parameter values needed for a fresh execution. Local variables from the first run are not captured. Repeated calls replace the stored repeat script; invalid code leaves the previous value unchanged.
Without action_id, a call inside an executing menu script targets that action. Outside a script, it requires the latest repeatable operator to be a MenuWeave action. During initial execution the change is committed only if the action succeeds.
For a delayed dialog callback, capture ownership while the script is executing. This is a callback fragment to integrate into your own dialog:
repeat_action_id = ih_menu_weave["repeat_action_id"]
def on_confirmed(amount): bpy.ops.wm.ih_menu_weave_set_repeat_code( action_id=repeat_action_id, code=f"bpy.context.active_object.location.x += {amount!r}", )The injected set_repeat_code(code) helper is already bound to its action; the same helper is available as ih_menu_weave["set_repeat_code"]. An explicit owner never falls back to another action. Undo, file loading, reload, or history eviction can invalidate the owner and cause an error. Updating repeat code does not move its owner above newer operations in native history.
Repeating a script that launches a dialog or modal tool can launch that tool again. MenuWeave does not record arbitrary gestures or infer the completed result of asynchronous Python code. Keep reusable operator work in execute() and parameters in Blender RNA properties when implementing repeatable tools.
Toggle global hotkeys
Section titled “Toggle global hotkeys”From a Python action inside a root branch:
bpy.ops.wm.ih_menu_weave_toggle_global_hotkeys()Outside an executing action, pass the known root menu’s internal ID:
bpy.ops.wm.ih_menu_weave_toggle_global_hotkeys(menu_id="YOUR_ROOT_MENU_ID")The no-argument form resolves the root that owns the executing action. The explicit menu_id is an internal folder ID, not its display name. Only roots have independent Global Priority. State is persistent and restored with preferences or JSON imports.
Global shortcuts obey the root’s workspace, editor, and mode filters. Among active roots, the newest activation wins duplicate combinations. Text Editor and Console allow normal unmodified and Shift-only text entry to pass through.
Disable all global hotkeys
Section titled “Disable all global hotkeys”bpy.ops.wm.ih_menu_weave_clear_global_hotkeys()Disables every configured root-menu Global Priority binding. This is the emergency reset if global action shortcuts interfere with other work. It does not delete menus, erase action shortcuts, or modify Blender’s native keymaps.
Toggle hidden actions
Section titled “Toggle hidden actions”bpy.ops.wm.ih_menu_weave_toggle_show_hidden_actions()Temporarily shows actions whose Show in Menu setting is off, or restores saved visibility when toggled again. The saved eye values are unchanged. Hidden actions retain their shortcuts even when excluded from visual navigation.
Toggle hidden folders
Section titled “Toggle hidden folders”bpy.ops.wm.ih_menu_weave_toggle_show_hidden_menus()Temporarily reveals hidden folders independently from the hidden-action mode. It changes runtime visibility, not the saved folder eyes. Each reveal mode locks only its own entry-type visibility controls while active.
Script-local queries and cleanup
Section titled “Script-local queries and cleanup”Inside a MenuWeave action, ih_menu_weave also exposes query helpers:
global_priority_active = ih_menu_weave["global_hotkeys_active"]()hidden_actions_visible = ih_menu_weave["show_hidden_actions_active"]()The dictionary and its bound helpers exist in the action execution environment; they are not globals injected into arbitrary Blender scripts. Service controls are excluded from repeat history and should be kept separate from scene-editing code.
MenuWeave closes its own overlays and removes its own bindings on disable. Your script must clean up any operators, draw handlers, timers, or temporary data it creates. Test initial execution, repetition, changed context, Undo/Redo, cancellation, and any delayed callbacks before sharing an action.