blender.execute_python
Run Python code inside a live Blender session to create or edit objects and return structured data through the result variable.
Instructions
Execute Python inside the running Blender and return whatever the snippet left
in a variable named result.
code: statements to run. import bpy, import mathutils and the standard
library are available. Anything that touches the network, spawns
processes, reads or writes files, or reaches for eval/exec/import is
rejected with VALIDATION_ERROR before Blender is contacted.
Assign a JSON-serialisable value to result to get structured data back;
otherwise only a summary is returned.
Otherwise, if the server was started with ALLOW_PYTHON_EXECUTION=false,
the call is refused with PYTHON_EXECUTION_DISABLED without contacting Blender.Example: import bpy bpy.ops.mesh.primitive_uv_sphere_add(location=(0, 0, 1)) obj = bpy.context.object obj.name = "Ball" result = {"created": obj.name, "verts": len(obj.data.vertices)}
This tool is meant for a trusted, local AI client. It is a policy screen, not a sandbox: Blender's own API is powerful enough to do damage, and enabling this tool should be a deliberate choice.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||