blender_python_exec
Execute Python code inside Blender to automate scene manipulation, object editing, materials, or rendering. Returns results, captures stdout/stderr, and supports live or headless Blender sessions.
Instructions
Execute a Python script in Blender's context synchronously. Provide either 'code' (inline Python string) or 'script_path' (path to a .py file), not both. The script has access to 'bpy', 'mathutils', and an 'args' dict with your supplied arguments. Set 'result' in the script to return a JSON-serializable value. Returns the result, captured stdout/stderr, and execution duration. Use transport='bridge' for the live Blender add-on session, or transport='headless' to run the script in a separate blender -b process. For long-running tasks like baking, use blender_python_exec_async.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | ||
| code | No | ||
| transport | No | bridge | |
| blend_file | No | ||
| script_path | No | ||
| factory_startup | No | ||
| timeout_seconds | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |