Guides
Can Claude write Blender Python scripts that actually run?
Can Claude write Blender Python (bpy) scripts? What it gets right, why scripts fail, how to run them safely, and prompts that produce working code.
6 min read

Quick answer
Can Claude write Blender Python scripts?
Yes. Claude writes bpy code well for modelling from primitives, batch renaming, transforms, materials, exports and add-on scaffolding. Scripts fail mostly on operators that need a specific context and on API changes between Blender versions, so run them on a saved copy, read the errors back to Claude, and keep the versions that work.
The short answer
Claude is good at Blender Python. It knows the bpy module, the difference between data and operators, and most of the common modelling, material and export calls. What goes wrong is predictable:
- Context errors. Many
bpy.opsoperators expect a particular mode, area or selection. Code that runs fine in the viewport fails from a script with a "context is incorrect" error. - Version drift. Blender's Python API changes between releases. Code written for an older version can call something that's been renamed or removed.
- Assumptions about your scene. Claude guesses object names, units or what's selected unless you tell it, or unless it can look.
Each has a simple fix. Once you know them, Claude becomes a fast way to automate the parts of Blender you repeat.
Two ways to run Claude's code
Copy and paste
Ask in any Claude chat, copy the script, and run it in Blender's Scripting workspace: paste into the Text Editor and press Run Script. Errors print to the system console, and tracebacks also show in the Info editor. Paste the error back into the chat.
This works on any plan and needs no setup. The weak spot is that Claude can't see your scene, so tell it the object names, what's selected and your Blender version.
Through Blender MCP
With an MCP server connected, Claude runs the code itself and reads the result:
- The official Blender Lab MCP server includes tools to execute code, summarise the blend file and objects, take screenshots, and look up Python API docs. That last one helps with version drift.
- The community MCP for Blender add-on exposes
execute_blender_code, which runs any Python you or Claude send.
Setup for both is in Blender MCP with Claude. Both run code in your real session, so save first. The community add-on's socket has no authentication, so keep it on localhost. It also has a safe mode, set with BLENDER_MCP_SAFE_MODE=1.

What Claude does well
- Building from primitives. "Make a bookshelf: two sides 2 m tall, five shelves 0.8 m wide, 2 cm thick." Clear dimensions produce clean scripts.
- Batch operations. Rename by pattern, apply transforms on every selected object, set origins, assign one material to a collection.
- Procedural layouts. Rows of fence posts, a grid of floor tiles, scattering rocks along a curve with random rotation and scale.
- Export loops. One FBX or GLB per object, with your settings, into a folder relative to the
.blend. - Materials. Building a Principled BSDF node tree, plugging in image textures and setting values.
- Add-on scaffolding. A panel in the N sidebar with a few buttons wired to operators. For a deeper look, see Can ChatGPT write Blender add-ons?, which applies equally to Claude.
Prompts that produce working code
Give Claude what a human scripter would ask for:
- your Blender version ("Blender 5.3")
- the mode to run in ("from Object Mode")
- object names, or "act on the selected objects"
- units ("metres; 1 unit = 1 m")
- the output you want ("print the triangle count of each object at the end")
Example:
"Blender 5.3, Object Mode. For each selected mesh: apply rotation and scale, set the origin to the bottom centre of its bounding box, and print its name, dimensions and triangle count. Use bpy.data and object methods where you can instead of bpy.ops."
That last sentence matters. Direct data access, such as setting obj.location or obj.data values, doesn't depend on UI context the way operators do. When an operator is the only way, ask Claude to set the active object and selection explicitly first, or to use a context override.
Fixing the common errors
"Context is incorrect" or "poll() failed"
The operator needs a mode or area it isn't getting. Paste the full traceback and say "this ran from the Text Editor". Claude will usually switch to a data-level approach or set up the context. For example, it might call bpy.ops.object.mode_set(mode='OBJECT') first and select the target object.
AttributeError on a module or property
That usually means API drift. Tell Claude your exact version. Through the official MCP server, ask it to "check the Python API docs for this call first".
It ran but did nothing
The script probably acted on nothing: wrong names, nothing selected, or the wrong scene. Ask Claude to print what it found before acting, for example "print the names of the objects you'll change, then change them".
It ran and broke something
Undo (Ctrl+Z) usually works for operator-based changes. Data-level changes from a script may not undo cleanly, which is why you work on a saved copy. For anything destructive, ask for a dry run that only reports.
A 30-second review before you run
Read the script before pressing Run, even when you trust Claude. Look for:
- Deletes and joins. Any
remove,deleteorjoincall should act on objects the script names or lists first. - File writes. Saves and exports should target a copy or an
//export/folder, never overwrite the.blend. - Hard-coded paths.
C:\Users\...or/Users/...paths will break on a teammate's machine. Paths relative to the blend file start with//. - Loops over everything.
for obj in bpy.data.objectstouches cameras, lights and hidden objects too. Usually you want selected meshes only. - Network or shell calls. A modelling script has no reason to download anything or run shell commands.
Keep the scripts that work
Once a script does exactly what you want, don't rely on Claude to write it identically next time. Save it:
- in a text block inside your template
.blend, or - in a skill's
scripts/folder, so Claude runs your tested version instead of improvising (how to write one).
What Claude can't do with scripts
- Sculpt or hand-model organic forms. It can stack primitives into a rough creature, but a convincing dragon from code is a weekend of iteration. Generating the mesh is faster.
- See without a screenshot. Copy-paste Claude is blind. MCP Claude sees what screenshots and scene summaries show it, which is not the same as you orbiting the viewport.
- Guarantee version-proof code. Test on your version, every time.
- Replace retopology judgement. It can run Remesh or Decimate with sensible values, but deciding where edge loops must go for a face to deform is still a modelling decision.
Pairing scripts with generated models
A practical split for prop-heavy scenes is to generate the detailed objects and script everything around them. Generate a mesh in Vi3W from text or an image, run Clean shape to a face budget, download GLB, and ask Claude for a script that imports, scales, names and scatters the copies. If the Vi3W MCP server is connected (it launched today), Claude can do the generation step from the same chat too. See Can Claude generate a 3D model from text?.
Frequently asked questions
claude blender python
Claude writes Blender Python (the bpy API) you can paste into the Scripting workspace, or run directly through Blender MCP. Tell it your Blender version, and paste any error back so it can fix the call.
can claude code create blender models
Yes, from code: Claude Code can build models out of primitives, modifiers and procedural steps through Blender MCP. That suits architecture, kits and props with clear shapes. Detailed organic models are better generated and then imported.
what programming language does blender use
Blender's scripting and add-on language is Python, through the bpy module. Blender itself is written mostly in C and C++, but everything you'd automate (scenes, objects, materials, exports) is reachable from Python.
can claude code control blender
Yes, through an MCP server. With the official Blender MCP server or the community MCP for Blender add-on connected, Claude Code can run Python inside the open Blender session, read the scene and take screenshots.
Last reviewed

