/blender-developer-tools:depsgraph-and-evaluated-datafrom blender-developer-tools
Guides users to read evaluated geometry via the dependency graph (evaluated_depsgraph_get, evaluated_get, to_mesh, to_mesh_clear) instead of raw obj.data. Use when modifiers, shape keys, armatures, or geometry nodes are missing from exported or measured geometry.
Ships in blender-developer-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this skill when the user:
evaluated_depsgraph_get, evaluated_get, to_mesh, to_mesh_clearobj.data.vertices and gets unexpectedly raw geometrybpy.data.objects['Cube'].data.vertices does not return what the user sees in the viewport. It returns the mesh datablock as authored, before any modifier, armature, shape key, or geometry nodes evaluation.
The viewport shows evaluated geometry: the result of running the full dependency graph. Anything that downstream code consumes (renderers, exporters, measurement tools) almost always wants the evaluated form, not the raw form.
authored mesh (obj.data)
|
v
modifier stack
shape keys
armature deform
geometry nodes
|
v
evaluated mesh (what you see)
import bpy
def get_evaluated_mesh(obj):
"""Return a temporary mesh datablock with all modifiers applied.
The caller must call obj_eval.to_mesh_clear() when done to free the
temporary mesh. Do not store this mesh; treat it as read-only and
short-lived.
"""
depsgraph = bpy.context.evaluated_depsgraph_get()
obj_eval = obj.evaluated_get(depsgraph)
mesh_eval = obj_eval.to_mesh()
return obj_eval, mesh_eval
Three steps:
bpy.context.evaluated_depsgraph_get() returns the current depsgraph and forces an evaluation if anything is dirty. There is no "the depsgraph"; each scene has its own, and switching view layers gives you a different one.obj.evaluated_get(depsgraph) returns an evaluated proxy. The proxy has .data, .matrix_world, etc. just like a normal object, but they reflect post-modifier state.obj_eval.to_mesh() returns a temporary mesh datablock. It is owned by the depsgraph and remains valid only until you call obj_eval.to_mesh_clear() or the depsgraph re-evaluates.Every to_mesh() must be paired with a to_mesh_clear(). One temporary mesh is held per evaluated object until to_mesh_clear() or re-evaluation. A second to_mesh() on the same object frees the previous temporary mesh and returns a fresh one, so the earlier Python reference raises ReferenceError (measured on 4.5.11 and 5.2.1). A missing clear therefore does not multiply per call on one object. Looping over many objects without clearing holds one per object. If you skip the clear:
obj_eval, mesh_eval = get_evaluated_mesh(obj)
try:
for v in mesh_eval.vertices:
process(v.co)
finally:
obj_eval.to_mesh_clear()
Use try/finally. Do not rely on garbage collection; bpy_struct references do not trigger Python finalization.
This exporter writes vertex positions and triangle indices for the evaluated geometry of every selected mesh object. It applies all modifiers, armature deformation, and geometry nodes, and uses obj.matrix_world so positions are in world space.
import bpy
def export_evaluated_geometry(filepath):
depsgraph = bpy.context.evaluated_depsgraph_get()
with open(filepath, 'w', encoding='utf-8') as f:
vertex_offset = 1
for obj in bpy.context.selected_objects:
if obj.type != 'MESH':
continue
obj_eval = obj.evaluated_get(depsgraph)
mesh_eval = obj_eval.to_mesh()
try:
mesh_eval.calc_loop_triangles()
world_matrix = obj_eval.matrix_world
for v in mesh_eval.vertices:
co = world_matrix @ v.co
f.write(f"v {co.x} {co.y} {co.z}\n")
for tri in mesh_eval.loop_triangles:
indices = [tri.vertices[i] + vertex_offset for i in range(3)]
f.write(f"f {indices[0]} {indices[1]} {indices[2]}\n")
vertex_offset += len(mesh_eval.vertices)
finally:
obj_eval.to_mesh_clear()
print(f"Wrote {filepath}")
import bpy
def get_world_position(obj, vertex_index):
"""Return the world-space position of a vertex after armature deformation."""
depsgraph = bpy.context.evaluated_depsgraph_get()
obj_eval = obj.evaluated_get(depsgraph)
mesh_eval = obj_eval.to_mesh()
try:
local = mesh_eval.vertices[vertex_index].co
return obj_eval.matrix_world @ local
finally:
obj_eval.to_mesh_clear()
Read raw obj.data directly when:
For most read paths, prefer the depsgraph route. The cost is one indirection; the safety is enormous.
The USD and Alembic exporters take evaluation_mode; the OBJ exporter's equivalent is export_eval_mode with different values. Passing evaluation_mode= to wm.obj_export raises TypeError.
| Exporter | Parameter | Values | Default |
|---|---|---|---|
wm.usd_export | evaluation_mode | 'RENDER', 'VIEWPORT' | 'RENDER' |
wm.alembic_export | evaluation_mode | 'RENDER', 'VIEWPORT' | 'RENDER' |
wm.obj_export | export_eval_mode | 'DAG_EVAL_RENDER', 'DAG_EVAL_VIEWPORT' | 'DAG_EVAL_VIEWPORT' |
render_levels, render-only modifiers). Use for final exports.Note the OBJ default is the opposite of USD's.
Default export_subdivision='BEST_MATCH' writes the cage plus
subdivisionScheme = catmullClark. VIEWPORT and RENDER files are then
identical — evaluation_mode is silent. Pass export_subdivision='TESSELLATE'
to make the mode observable. Catmull-Clark on a cube is closed form:
verts = 2 + 6 × 4^n (n=1 → 26, n=2 → 98).
bpy.ops.wm.usd_export(
filepath="/tmp/scene.usdc",
evaluation_mode='RENDER',
export_subdivision='TESSELLATE',
)
When you build your own exporter on top of evaluated_depsgraph_get(), the depsgraph defaults to viewport evaluation. Switch to render evaluation by getting the depsgraph from a temporary scene render context (advanced; for most cases the viewport depsgraph is fine).
obj.data.vertices and calling it "what the user sees". It is not. This is the single most common AI exporter bug.to_mesh_clear. Each evaluated object keeps its temporary mesh until it is re-evaluated or freed. Across a whole-scene export that is a second copy of every mesh held at once.mesh_eval past the cleanup point. Once to_mesh_clear runs, the mesh datablock is freed. Any references become dangling.evaluated_get without the depsgraph argument. The signature is obj.evaluated_get(depsgraph); passing nothing raises a TypeError.obj.data as identical to obj_eval.data. They are different mesh datablocks. The first is the source; the second is post-evaluation.matrix_world after evaluating. obj.matrix_world and obj_eval.matrix_world may differ (parent constraints evaluate during depsgraph). Use obj_eval.matrix_world for world-space positions.to_mesh() and no clear. One temporary mesh is held per evaluated object until to_mesh_clear() or re-evaluation, so a scene-wide loop ends up holding an evaluated copy of every mesh at once. Repeated calls on the same object do not stack; each frees the previous one.evaluation_mode without export_subdivision='TESSELLATE'. Default BEST_MATCH writes the cage plus subdivisionScheme = catmullClark, so RENDER and VIEWPORT files match and the mode looks like a no-op.export_apply=True as "apply object transforms". RNA is "Apply modifiers (excluding Armatures) to mesh objects". Unapplied non-uniform object scale lands on the glTF node, Y-up permuted (sx, sz, sy); POSITION stays local. Witness: examples/unapplied-scale-gltf/.The depsgraph API has been stable since 2.80. The patterns shown here work identically on 4.5 LTS and 5.1.
In 5.0 the underlying Animation 2025 work changed how armature evaluation interacts with the depsgraph in some edge cases (multi-data-block animation via slotted actions). For mesh deformation specifically, the API surface and behavior shown here are unchanged.
prefer-data-over-ops-in-loops: same principle, different motivation.mesh-editing-and-bmesh: bmesh has its own load-edit-free contract.depsgraph-evaluated-mesh.py for the minimal copy-paste pattern.usd-export-evaluation-mode.py for the exporter parameter.usd-export-evaluation-mode for the TESSELLATE closed form versus the BEST_MATCH cage.unapplied-scale-gltf for object scale vs export_apply (modifiers only).Each example runs headless, asserts the contract, and exits non-zero when it breaks. Run one with blender --background --python <script> --; pass a falsifier flag to watch the check fail.
armature-bend: Rigging end to end in the data API — edit_bones chain construction, name-bound vertex groups with smoothstep blend zones, posing, and depsgraph evaluation. Falsify: --zero-curl (exit 8).boolean-exact-volume: The Boolean modifier on the EXACT solver. Falsify: --float-solver (exit 3).car-mirror-symmetry: A stylized hatchback lofted as one half (52 stations, 13-point rings) and completed by the Mirror modifier, evaluated through the depsgraph. Falsify: --no-mirror (exit 5).depsgraph-export: The depsgraph lifetime contract — evaluated_get().to_mesh() paired with to_mesh_clear() — measured against an OBJ export of the same object. Falsify: --unevaluated (exit 5).eval-mesh-datablock-name: Pathology witness for the 5.2 change in Object.evaluated_get(depsgraph).data.name. Falsify: --assume-distinct-names (exit 6).gltf-export-roundtrip: A sci-fi supply crate exported to glTF and re-imported, verifying the round-trip against the depsgraph-evaluated mesh within float tolerances. Falsify: --no-yup (exit 9).gltf-skin-roundtrip: A rigged mech scorpion exported to glTF with skins and re-imported, verifying the skinning contract the geometry round-trip left uncovered. Falsify: --no-skins (exit 5).lattice-deform: A 2x2x2 Lattice modifier set to KEY_LINEAR on all three axes, with two top control points moved through LatticePoint.co_deform, read back through the depsgraph (evaluated_get, to_mesh, to_mesh_clear). Falsify: --bspline (exit 4).lod-decimate-chain: A retro rocket at LOD0/1/2 via the Decimate modifier evaluated through the depsgraph, with a wireframe of each evaluated mesh. Falsify: --no-decimate (exit 6).ray-cast-space: Object.ray_cast is object-local while Scene.ray_cast is world space. Falsify: --world-to-object (exit 4).soccer-ball-goldberg: A soccer ball as a Goldberg polyhedron: a bmesh icosphere truncated at 1/3 per edge, faces ordered by link-topology walks, panels bound by face vertex count. Falsify: --invert-bind (exit 13).solidify-even-thickness: Solidify's use_even_offset on a folded strip. Falsify: --no-even (exit 4).usd-export-evaluation-mode: The USD exporter evaluation_mode chooses viewport versus render modifier quality. Falsify: --subdivision BEST_MATCH (exit 4).Short standalone patterns to copy. Each one runs in CI on 5.2 and 4.5 with a check and a falsifier.
bpy.types.Object.evaluated_get: https://docs.blender.org/api/current/bpy.types.Object.html#bpy.types.Object.evaluated_getbpy.types.Object.to_mesh: https://docs.blender.org/api/current/bpy.types.Object.html#bpy.types.Object.to_meshbpy.types.Object.to_mesh_clear: https://docs.blender.org/api/current/bpy.types.Object.html#bpy.types.Object.to_mesh_clearbpy.types.Depsgraph: https://docs.blender.org/api/current/bpy.types.Depsgraph.htmlbpy.context.evaluated_depsgraph_get: https://docs.blender.org/api/current/bpy.context.htmlWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
27 skills in this plugin
/addon-scaffoldingScaffold a Blender add-on as an Extensions Platform package: blender_manifest.toml, modular file layout, register_classes_factory, symmetric register/unregister. Use when the user starts a new add-on or extension, writes or fixes blender_manifest.toml, asks which layout or registration pattern to use on Blender 4.5 LTS or 5.x, or has classes that fail to register or unregister cleanly. Targets 5.2 LTS with 4.5 LTS fallback./ai-mesh-cleanupOrdered cleanup for an imported generated or scanned mesh before it goes to an engine: scene units, apply rotation and scale, origin to base, recalculate normals, evaluated triangle count, decimate to a budget, convex collider. Use when the user has a GLB, glTF or FBX that is not engine-ready, mentions unit scale, unapplied transforms, triangle budget, LODs or a collision hull, or is about to run mesh operations on an import without checking its scale. Targets 5.2 LTS with 4.5 LTS fallback./bake-high-to-lowCage-bake high-poly surface detail onto a low-poly target as a tangent-space normal map with bpy.ops.object.bake (Cycles, selected-to-active, active Image Texture node, UV layer, save_render). Use when the user wants a normal map from a dense mesh onto a game-resolution or decimated LOD, mentions cage_extrusion or use_selected_to_active, or gets a bake that returns CANCELLED, comes out black or flat, or fails with 'No active UV layer found'. Targets 5.2 LTS with 4.5 LTS fallback.npx claudepluginhub tmhsdigital/blender-developer-tools --plugin blender-developer-toolsOther plugins' skills for the same job