Execute Code
execute_codeRun Python or MEL code in an active Maya session to inspect scenes, build assets, or verify results. Requires an existing session; changes cannot be undone.
Instructions
Execute arbitrary Python or MEL code in an active Maya session.
Runs arbitrary code with full session privileges of the connected Maya process. Execution is irreversible and cannot be undone (modifications do not register an automatic undo chunk). The return value shape is governed by the result_type envelope parameter. Requires an established Maya session (discoverable via list_sessions).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python or MEL code to execute in Maya. | |
| result_type | No | Return envelope handling for the execution result: - "NONE": Execute statements, don't capture result (returns None) - "JSON": Evaluate expression, JSON-encode result - "RAW": Evaluate expression, return string representation | NONE |
| session_key | No | Maya session key (optional if only one session exists). |