/blender-skills:blender-python-scriptingfrom blender-skills
Provides expert guidance for Blender 5.x Python scripting using bpy: custom operators, UI panels, add-on development, context management, handlers, timers, property system, batch processing, and data model access. Prefers Blender MCP Server for live execution.
Ships in blender-skills. 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.
Read when SKILL.md points to them.
This skill provides expert guidance for Blender 5.x Python scripting: writing custom operators, building UI panels, developing add-ons, managing context, using handlers and timers, working with the property system, batch processing, and accessing Blender's data model. The reference files contain complete templates and the data model hierarchy.
Prefer the official Blender MCP Server (Blender Lab, Blender 5.1+) for executing scripts, inspecting datablocks, mutating scene state directly in a running Blender session. Fall back to emitting Python scripts only when the MCP server is not connected.
Detection: at session start, look for tools whose names match execute_blender_code, get_objects_summary, or search_api_docs — these belong to the official blender-mcp server. If any are present, MCP is available.
Tools used by this skill:
execute_blender_code — run bpy Python in the live session (primary action)get_objects_summary, get_object_detail_summary — inspect scene state before mutatingget_blendfile_summary_datablocks / _missing_files / _of_linked_libraries / _path_info / _usage_guess — inventory the filesearch_api_docs, get_python_api_docs, search_manual_docs — confirm correct API/operator names before calling themget_screenshot_of_window_as_image / _as_json, get_screenshot_of_area_as_image — verify visual resultsjump_to_tab_by_name, jump_to_tab_by_space_type, jump_to_view3d_object_by_name, jump_to_view3d_object_data_by_name — drive the UI to make changes visiblerender_thumbnail_to_path, render_viewport_to_path — capture quick visual feedbackWorkflow: inspect with a get_* / search_* tool → mutate via execute_blender_code → verify with a screenshot or summary tool. Keep code blocks small and idempotent so failures are easy to localize.
Setup: see docs/blender-mcp-setup.md.
references/python_api.md for operator templatesreferences/python_api.mdreferences/data_model_reference.mdreferences/python_api.mdreferences/python_api.mdbl_info["blender"] to (5, 1, 0) for version gating in add-onsint | None instead of Optional[int]) — now fully supportedbpy.ops.anim.convert_legacy_action — removed; layered actions handle this automaticallybpy.ops.pose.apply_to_basis() — bake current pose as rest poseNodeSocketFont for font dataA proper Blender add-on follows this layout:
my_addon/
├── __init__.py # bl_info, register(), unregister()
├── operators.py # Custom operators
├── panels.py # UI panels
├── properties.py # PropertyGroups
├── preferences.py # AddonPreferences (optional)
└── utils.py # Shared utilities
bl_info = {
"name": "My Add-on",
"author": "Author",
"version": (1, 0, 0),
"blender": (5, 0, 0),
"location": "View3D > Sidebar > My Tab",
"description": "Short description",
"category": "Object",
}
import bpy
class MY_OT_my_operator(bpy.types.Operator):
bl_idname = "my.my_operator"
bl_label = "My Operator"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
# ... do work ...
return {'FINISHED'}
class MY_PT_my_panel(bpy.types.Panel):
bl_label = "My Panel"
bl_idname = "MY_PT_my_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "My Tab"
def draw(self, context):
layout = self.layout
layout.operator("my.my_operator")
classes = (MY_OT_my_operator, MY_PT_my_panel)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
if __name__ == "__main__":
register()
ADDON_OT_name → bl_idname = "addon.name"ADDON_PT_nameADDON_MT_nameADDON_UL_nameADDON_PG_name (convention, not enforced)ADDON_HT_nameBlender operations depend on the current context (active object, mode, area type). Many bpy.ops.* calls will fail if context is wrong.
Rule: Always check context before calling operators. Use poll() methods to guard operators.
# Modern context override using temp_override (4.0+)
with bpy.context.temp_override(active_object=obj, selected_objects=[obj]):
bpy.ops.object.delete()
# Override with area/region for UI-dependent ops
area = next(a for a in bpy.context.screen.areas if a.type == 'VIEW_3D')
region = next(r for r in area.regions if r.type == 'WINDOW')
with bpy.context.temp_override(area=area, region=region):
bpy.ops.view3d.camera_to_view()
# Safe mode switch
if bpy.context.object and bpy.context.object.mode != 'EDIT':
bpy.ops.object.mode_set(mode='EDIT')
# Always return to object mode when done
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops in background mode: Many viewport operators fail in --background mode. Use direct data API (bpy.data.*) instead.bpy.context.temp_override() or avoid bpy.ops in handlers.context.active_object is not None before operations.context.object.mode.bpy.context.view_layer.update() or depsgraph.update() if needed.display_type values depend on object type: 'PLAIN_AXES' is only valid for Empties. Mesh objects use 'BOUNDS', 'WIRE', 'SOLID', or 'TEXTURED'.import bpy, os
scenes_dir = "/path/to/blend/files"
output_dir = "/path/to/output"
for filename in os.listdir(scenes_dir):
if filename.endswith(".blend"):
filepath = os.path.join(scenes_dir, filename)
bpy.ops.wm.open_mainfile(filepath=filepath)
bpy.context.scene.render.filepath = os.path.join(
output_dir, filename.replace(".blend", ".png")
)
bpy.ops.render.render(write_still=True)
import bpy
for obj in bpy.data.objects:
if obj.type == 'MESH':
# Select only this object
bpy.ops.object.select_all(action='DESELECT')
obj.select_set(True)
bpy.context.view_layer.objects.active = obj
# Apply all modifiers
for mod in obj.modifiers:
bpy.ops.object.modifier_apply(modifier=mod.name)
blender --background scene.blend --python my_script.py
blender --background --python batch_render.py -- --input /files --output /renders
Access custom args after --:
import sys
argv = sys.argv[sys.argv.index("--") + 1:]
dir() and help(): Use in Python Console to explore API objectsbpy.context.copy(): Returns a dict of the current context for inspectionprint() statements or use traceback.print_exc() in exception handlers| Type | Registration | Values |
|---|---|---|
BoolProperty | bpy.props.BoolProperty() | True/False |
IntProperty | bpy.props.IntProperty() | min, max, default, step |
FloatProperty | bpy.props.FloatProperty() | min, max, default, precision |
StringProperty | bpy.props.StringProperty() | default, maxlen, subtype |
EnumProperty | bpy.props.EnumProperty() | items=[(id, name, desc)] |
FloatVectorProperty | bpy.props.FloatVectorProperty() | size, default, subtype |
IntVectorProperty | bpy.props.IntVectorProperty() | size, default |
BoolVectorProperty | bpy.props.BoolVectorProperty() | size, default |
PointerProperty | bpy.props.PointerProperty() | type=PropertyGroup |
CollectionProperty | bpy.props.CollectionProperty() | type=PropertyGroup |
'PIXEL', 'PERCENTAGE', 'FACTOR', 'ANGLE', 'TIME', 'DISTANCE''COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'EULER', 'QUATERNION', 'XYZ''FILE_PATH', 'DIR_PATH', 'FILE_NAME', 'BYTE_STRING', 'PASSWORD'For complete templates including operators (basic, modal, file dialog, invoke with props), panels (conditional, sub-panels, collapsible), PropertyGroups, handlers, timers, keymaps, and context overrides, consult references/python_api.md.
For the complete Blender data hierarchy (bpy.data.*), ID types, object types, mesh/curve/armature data access patterns, and depsgraph usage, consult references/data_model_reference.md.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
8 skills in this plugin
/blender-animation-riggingBlender 5.x animation and rigging — keyframes, FCurves, layered actions, drivers, constraints, armatures, IK/FK, shape keys, NLA editor, and bone collections via Python (bpy). Includes 5.1 changes (Smooth Gaussian FCurve modifier, Apply to Basis, layered action performance)./blender-compositing-nodesBlender 5.x compositor nodes — post-processing, color grading, denoising, keying, glare, depth of field, render pass separation, multi-layer EXR output, and scripting compositing pipelines via Python (bpy). Includes 5.1 changes (Sequencer Strip Info, Mask to SDF, Mix node alpha improvements)./blender-geometry-nodesBlender 5.x geometry nodes — procedural modeling, scattering, mesh/curve/volume ops, simulation zones, repeat zones, Bone Info, Font socket, UV nodes, volume grid nodes, and scripting node trees via Python (bpy). Includes 5.0 and 5.1 changes./blender-modeling-modifiersBlender 5.x modifiers, bmesh API, mesh editing operators, sculpting setup — SubSurf, Boolean, Array, Mirror, Bevel, bmesh procedural mesh creation, and modeling pipelines via Python (bpy). Includes 5.1 changes (Boolean speed, Corrective Flip Normals, UV improvements)./blender-physics-simulationBlender 5.x physics simulations — rigid body, cloth, fluid/smoke/fire (Mantaflow), soft body, particles, force fields, collisions, and simulation baking/caching via Python (bpy)./blender-scene-renderingBlender 5.x scene setup, render engines (Cycles/EEVEE), output formats, import/export (FBX/glTF/OBJ/USD/Alembic), linking/appending, color management (AgX/Filmic), view layers, viewport config, and world/environment setup via Python (bpy). Includes 5.1 changes (AVIF, HTJ2K, OpenColorIO 2.5, Light Path in World).npx claudepluginhub ra100/blender-claude-plugin --plugin blender-skillsOther plugins' skills for the same job