
Errors When Asking AI to Write Python for Blender Are Two Types, and Neither Is Geometric
The errors I encounter when asking AI to write Python for Blender come in two kinds, and not one of them lies in geometry. First, Blender's API has changed after the point when the AI model was trained, so the code looks right but runs wrong on the version I have. Second, the most critical errors in a 3D model are invisible when rendering: the image looks beautiful but the 3D-printed object comes out broken. This post rewrites the fix procedure from @0xCodio (11/10/2026) in the order: pin the version, write straight into data instead of calling interface operations, unify units, count geometric errors by code, then only let AI "see" the result. For example, a test of 1,190 answers shows the rate of runnable code dropping from 91% down to 70% when Blender goes up to version 5.0.
This post is based on "Opus 5.5 Writes Blender Python for the Wrong Blender - and the Render Won't Tell You" by @0xCodio on X (11/10/2026), rewritten in English by OPCAIOS, shortened and explained. All benchmark numbers, software versions, and security information below belong to the original author; OPCAIOS has not independently verified them; please cross-check with current Blender documentation before applying to real work.

Loop in this post: each step has one machine-based check, only the step of viewing from 6 angles uses eyes (of AI). Diagram: OPCAIOS.
Two Errors, Not One
Error 1: What Is AI Aiming at the Wrong Blender Version?
Aiming at the wrong version is the situation where the AI model writes code for an old Blender while I run a new one. According to the author, one test ran 30 code-writing tasks on four Blender versions with ten models, each piece of code was run live in headless mode and had its own check, totaling 1,190 answers graded. Results:
- Rate of code that runs: 91% on Blender 3.6, only 70% on Blender 5.0.
- Rate at which models still say what has changed: from 81% down to 35%.
- Three groups of tasks (compositor, boolean solver, sequencer) got zero points on every model on Blender 5.0.
The clearest example: the identifier name of the EEVEE renderer changed from BLENDER_EEVEE to BLENDER_EEVEE_NEXT at version 4.2, then back to BLENDER_EEVEE at version 5.0. A model that learned the rename in between got it wrong now; a model that never learned it happened to be right by chance. This is an error of aiming at the wrong target, not a reasoning error.
Error 2: Why Is Geometric Error Invisible When Rendering?
Invisible error is a geometric error that breaks the 3D-printed object but still produces a perfect render image. It is an unclosed edge (non-manifold), a face with zero area, parts cutting into each other, cavities inside, and walls thinner than the printer nozzle. The author cites the official Blender page on MCP, where Blender itself records that an AI model once left out a Solidify modifier that would have doubled the polygon count, because that modifier does not affect the viewport. So the eye of a person, or the eye of AI looking at a render image, is not enough to detect it: I need a counting step by code, described in Step 4 below.
Step 1: Pin the version before everything else
Pinning the version means declaring the target Blender and Python versions right in the prompt, then having the program prove it runs on those versions. According to @0xCodio (2026), the current release is Blender 5.2.2 LTS, and 4.5 is still maintained. Python changed from 3.11 to 3.13 in version 5.1, and the bpy package only runs correctly on one Python version—there's no such thing as "close enough". For example, every session with Claude from Anthropic or ChatGPT from OpenAI should start with the system prompt template below:
Target Blender 5.2 LTS, Python 3.13. Do not use any API removed before it.
Rules:
- bpy.data and bmesh only; no bpy.ops.mesh.* and no bpy.ops.object.*
except where I have named one
- one Blender unit is one metre; declare MM = 0.001 and use it
- every dimension, clearance and wall thickness is a named module-level
constant, never inline
- boolean solver is EXACT unless I state the inputs are manifold
- end the script with the census asserts, not with a render
- after the code, list every API you used that changed in 4.0 or later
and state which release you are targeting for each
What does the version-pinning prompt mean and how do you run Blender?
The prompt above means: target Blender 5.2 LTS and Python 3.13; use only bpy.data and bmesh, no UI operators; one Blender unit is one metre and declare MM = 0.001; every dimension is a named constant; the boolean solver defaults to EXACT; end the script with census assertions, not a render; finally list every API that changed from 4.0 and state which version you are targeting for each. Then run Blender headless with this command:
blender --background --factory-startup \
--python-exit-code 1 \
--python build.py -- --out ./dist --mm 20
Two details that have each cost people a full day:
- Missing
--python-exit-codemeans errors in the script don't change Blender's exit status, so automated CI tests report green even though the script crashed. - Parameter order matters: put
-oafter the.blendfilename, otherwise opening the file overwrites the output path. Everything after--gets passed to Python viasys.argv.
Step 2: UI operators are only for people; scripts must write directly to data
Operators (the bpy.ops.* commands) are simulated mouse clicks, and per Blender's own documentation, these operators don't take data as parameters—they just return success or failure, and when the conditions aren't met they throw RuntimeError: ... context is incorrect without explaining why. Running headless with no UI, every bpy.ops.mesh.* command looks for an edit mesh context that doesn't exist, per Blender (2026) and @0xCodio.
So first, push the model to write directly to bpy.data and bmesh, for example when using Claude or ChatGPT. A sample code generation prompt for a 20 mm part:
Build the part described below as a single Python file.
<spec: outer dimensions, wall, clearances, holes, tolerance, export path>
Output the parameter block first as a table. I will assert against it.
The boolean solver is also a trap because the default is a trap: FLOAT is explicitly documented as "does not support overlapping geometry", MANIFOLD only works on closed meshes, and only EXACT survives messy input. Feeding AI-generated geometry to the default solver isn't a bug—it's documented behavior.
Step 3: ratio errors that slip past every review
Ratio errors are size mistakes off by tens or hundreds of times that still slip past reviews, usually from three facts about units combining together. First, according to Blender, choose a unit convention once and state it clearly at the start of the script (still the same in 2026):
MM = 0.001 # 1 Blender unit = 1 metre, so a 20 mm detail is 0.02
Next, the author stresses the glTF case: the spec mandates metre units, Y axis pointing up, and the exporter has no scale option, so one Blender unit goes out as exactly one metre.
Where do people misunderstand Blender units?
A block 20 mm on a side easily becomes 40 mm if you misread size=, so the "people think, reality" table below, according to the author, deserves to be pinned to every new Blender project checklist in 2026. These three misunderstandings cost users many hours of debugging each time they run into them:
| People think | Reality |
|---|---|
primitive_cube_add() creates a cube 1 unit on a side |
Creates a cube 2 units on a side; size= is the full edge length |
unit_settings.scale_length = 0.001 means "work in mm" |
Display only; geometry, physics, and file export ignore it |
| The file exporter carries your units | STL and OBJ carry no units — you must pass use_scene_unit or global_scale |
MM = 0.001 # 1 Blender unit = 1 metre, so a 20 mm detail is 0.02
The author stresses the glTF case: the spec mandates metre units, Y axis pointing up, and the exporter has no scale option — Blender units go out at 1:1 ratio, so one unit is one metre. The "people think — reality" table according to the author:
| People think | Reality |
|---|---|
| `primitive_cube_add()` creates a cube 1 unit on a side | Creates a cube 2 units on a side; `size=` is the full edge length |
| `unit_settings.scale_length = 0.001` means "work in mm" | Display only; geometry, physics, and file export ignore it |
| The file exporter carries your units | STL and OBJ carry no units — you must pass `use_scene_unit` or `global_scale` |
## Step 4: census by code what render images cannot answer
The author calls it "census": a block of code that runs at the end of the script to count invisible errors and halt the whole process if any exist.
```python
import bmesh
bm = bmesh.new(); bm.from_mesh(obj.data)
nonmanifold = sum(1 for e in bm.edges if not e.is_manifold)
flipped = sum(1 for e in bm.edges if e.is_manifold and not e.is_contiguous)
loose = sum(1 for v in bm.verts if not v.link_faces)
degenerate = sum(1 for f in bm.faces if f.calc_area() <= 1e-4)
from mathutils.bvhtree import BVHTree
tree = BVHTree.FromBMesh(bm, epsilon=1e-5)
selfhit = len(tree.overlap(tree))
assert (nonmanifold, flipped, loose, degenerate, selfhit) == (0, 0, 0, 0, 0)
assert abs(obj.dimensions.x - 0.020) < 1e-5 # correct size as specified
This block checks: non-manifold edges, edges with flipped face directions, loose vertices, degenerate faces, self-intersecting parts, and correct dimensions against the spec. The author describes a complete audit as eleven questions that a render image never answers.
A few technical points worth remembering:
- Measure before, look after. One common bug is
bpy.ops.object.modifier_apply(modifier="Boolean"); in headless runs, the way to survive is to grab the computed mesh:dg = bpy.context.evaluated_depsgraph_get()thenobj.evaluated_get(dg).to_mesh(). - Outside Blender, the
trimeshlibrary has anis_volumeproperty — meaning the object is closed, face order is consistent, and normals point outward. Weaker isis_watertight, and volume only makes sense if the mesh is already a solid block. - The 3D-Print Toolbox no longer ships with Blender but is now a community add-on, so an automated pipeline must install it itself. Default thresholds (minimum wall thickness 1 mm, overhang angle 45°) match consensus for 3D printing, but only hold true when one unit is one metre.
Step 5: loops and the prompts that control them
A loop is a sequence made up of a buffered system block, a specification, one code generation run, one headless run, a census pass, and a numeric patch. According to @0xCodio (2026), such a loop costs a few cents, while one Blender run takes only a few seconds. The price table cited is for Anthropic's Opus 5.5, per 1 million tokens: input $4, output $20, cache read $0.20, batch processing $2 for input and $10 for output. Check your provider's current price table, since OPCAIOS has not verified these rates.
Build images to make a summary table, not to judge. Once the census pass is done, create a composite of six orthographic views of the object and give it to the AI only to score the things geometry cannot say: proportion against the stated dimensions, whether features sit where they should, parts that read as floating or fused, and anything present that the spec did not ask for. A sample review prompt:
Six orthographic views of one part: front, back, left, right, top,
three-quarter. The census already passed, so do not comment on topology.
Judge only what geometry cannot: proportion against the stated dimensions,
whether features sit where the spec says, parts that read as floating or
fused, and anything present that the spec did not ask for.
List discrepancies against: <parameter table>
The practical method is to build geometry offscreen using GPU instead of full render, then composite the six labeled views into one image. Two constraints: Cycles cannot build into an offscreen frame so use EEVEE or Workbench; and Blender 5.2 adds gpu.init() correctly to get GPU when running --background.
The last step is numeric patching, not letting the AI rewrite the entire script:
Change constants in the parameter block only. Do not restructure, do not
rename, do not add geometry.
Apply exactly: <discrepancy list>
Return a diff.
On Blender's MCP
Blender's MCP is a server that lets the AI control Blender, and according to the author (2026) there is now an official MCP server from Blender Lab (add-on v1.0.3, Blender 5.1 and up), and their page itself warns that it will "run code generated by the model in Blender with no guardrails" and recommends using a virtual machine. The community server has around 28,700 stars on GitHub, talks over TCP on the local machine, no authentication, no encryption, and once had a path traversal flaw fixed in version 1.6.5. The author's conclusion: treat both as tools for a dev machine, not a machine holding real data. For example, if used with Anthropic's Claude Code, run it in a virtual machine. If you are new to MCP, read What is MCP? first.
When importing a model made by an AI 3D generator
If the model comes from a generative 3D AI, audit it more thoroughly, not less. According to the author, the 2026 trend has moved away from closed geometry: TRELLIS.2 even advertises open geometry and exposed surfaces as a feature — fine for clothing, plants, wrong for anything that will be printed. No paid model commits to being watertight.
The processing pipeline by script after import, in the correct order: validity check → census → fix with bmesh.ops (remove_doubles, recalc_face_normals, holes_fill, dissolve_degenerate) → scale and orient → boolean → finally quadriflow_remesh or voxel_remesh if topology is needed.
On the numbers for 3D printing: four public guides contradict each other by a factor of two to three on nearly everything. Only four numbers do all agree — overhang angle 45°, smallest hole Ø2.0 mm, fit clearance 0.5 mm, minimum wall thickness about 1.0–1.2 mm. Pass those four as named parameters, and anything else still in dispute leave as a default-valued argument. A hard constant in the correct code generator works for one printer and fails for the next.
Summary
Two things stand between a script that looks done and an object that actually works are: pinning versions and code-based checks. They're not overhead; they're why a loop that costs a few cents can be trusted. Applying this pattern outside Blender holds too: declare your target environment clearly, let machines verify what machines can verify, and only use eyes (human or AI) for the parts machines cannot verify.
Read more: AI writes code with wrong versions; Claude Code (or programming agents) for people who don't know how to code.
Source: @0xCodio on X, 11/10/2026 — rewritten and condensed by OPCAIOS; figures, versions, prices and security information per original author, not independently verified.
Translated from Vietnamese with AI. Read the original.
Want to apply this in your business?
Book a free 30-minute call (Vietnam time, in English or Vietnamese).
