← ClaudeAtlas

headless-batch-scriptinglisted

Run Blender headless via blender --background --python script.py for batch jobs. What changes without a UI, how to avoid UI-dependent operators, the temp_override pattern when ops must be used, and argparse after the -- separator.
TMHSDigital/Blender-Developer-Tools · ★ 13 · Code & Development · score 66
Install: claude install-skill TMHSDigital/Blender-Developer-Tools
# Headless Batch Scripting ## Trigger Use this skill when the user: - Wants to render, export, or process .blend files from a CLI or CI pipeline - Mentions `blender --background`, `--python`, "headless", "batch render", "no UI" - Has an operator script that fails with `RuntimeError: Operator bpy.ops.X.Y.poll() failed, context is incorrect` - Needs to pass arguments to a Blender Python script ## The basic shape ```powershell blender --background --python my_script.py ``` Or with a specific .blend file: ```powershell blender --background scene.blend --python my_script.py ``` Or with arguments after `--`: ```powershell blender --background scene.blend --python my_script.py -- --output out.png --frames 1,5,10 ``` `--background` (or `-b`) tells Blender not to launch a UI window. `--python` (or `-P`) runs a Python script. The script receives `sys.argv` containing everything after the `--` separator. ## What changes without a UI The Blender API is the same in headless mode but several context-dependent behaviors break: | Subsystem | Headless behavior | | --- | --- | | `bpy.context.window`, `bpy.context.area`, `bpy.context.region` | Often `None` | | `bpy.context.active_object` | `None` if no scene is loaded or no active object set | | `bpy.context.selected_objects` | Empty by default | | Most `bpy.ops.<editor>.*` operators | Fail with "context is incorrect" because they expect an editor that does not exist | | Modal operators | Cannot be used; no event loop | | Drag and