execute_blender_python
Run custom Python code inside Blender for advanced operations like bmesh surgery, geometry nodes, and bulk edits when structured tools aren't enough.
Instructions
Run Python inside Blender on the main thread. The escape hatch.
Use this when the structured tools cannot express what you need: bmesh surgery, geometry nodes, uncommon operators, bulk edits. Prefer the structured tools when they fit -- they validate inputs and return tidy results.
Captures stdout and stderr, returns the traceback on failure, and reports
which objects appeared or disappeared. Assign to a variable named result
(or pass return_expression) to send a value back.
This is TRUSTED LOCAL EXECUTION: the code has the same reach as Blender's own scripting console, in the user's live session. There is no shell tool, no subprocess and no outbound network in this bridge -- do not try to add them here.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python source. bpy, bmesh, mathutils, math, random, Vector, Matrix, Euler, Quaternion, C (context) and D (data) are already in scope. | |
| ignore_errors | No | Report an exception in the result instead of failing the call | |
| return_expression | No | Expression evaluated after the code runs; its value is returned as result_repr |