Neexo Blender Python Instructions

Guidance for Blender Python scripts, add-ons, subprocess rendering, generated assets, and 3D pipeline automation.

AuthorNeexoCore
Apply to**/*.py
Updated
blenderpython3d

Overview

Use these instructions for Blender add-ons, render-studio automation, and configurator asset pipelines.

API and Scripting Rules

  • Use bpy.data, bpy.context, and bpy.ops through the stable API — avoid internal/undocumented modules
  • Register operators and panels with proper bl_idname, bl_label, and bl_options
  • Always provide poll() methods on operators to prevent invalid context execution
  • Use bpy.app.handlers for persistent callbacks; clean up handlers on add-on unregister

Asset Pipeline Rules

  • Treat large GLB, EXR, HDR, and render files as assets, not chat context — summarize metadata instead
  • Prefer metadata summaries and small config files before reading generated output
  • Use relative paths in .blend files for portability across machines

Subprocess and Rendering

  • Keep subprocess execution deterministic and logged without exposing secrets
  • Use --background and --python flags for headless Blender rendering:
    blender --background scene.blend --python render_script.py -- --output /tmp/render
    
  • Parse arguments after -- using sys.argv[sys.argv.index("--") + 1:]
  • Validate with focused scripts or tests before broad render runs

Common Pitfalls

  • Do not call bpy.ops outside the correct context — use context overrides or temp_override()
  • Do not block the UI thread with long operations — use modal operators or background threads for heavy work
  • Always check bpy.app.version when targeting multiple Blender versions

Raw content

Copy this into your project — e.g. .instructions.md, .agent.md, or SKILL.md

## Overview

Use these instructions for Blender add-ons, render-studio automation, and configurator asset pipelines.

## API and Scripting Rules

- Use `bpy.data`, `bpy.context`, and `bpy.ops` through the stable API — avoid internal/undocumented modules
- Register operators and panels with proper `bl_idname`, `bl_label`, and `bl_options`
- Always provide `poll()` methods on operators to prevent invalid context execution
- Use `bpy.app.handlers` for persistent callbacks; clean up handlers on add-on unregister

## Asset Pipeline Rules

- Treat large GLB, EXR, HDR, and render files as assets, not chat context — summarize metadata instead
- Prefer metadata summaries and small config files before reading generated output
- Use relative paths in `.blend` files for portability across machines

## Subprocess and Rendering

- Keep subprocess execution deterministic and logged without exposing secrets
- Use `--background` and `--python` flags for headless Blender rendering:
  ```bash
  blender --background scene.blend --python render_script.py -- --output /tmp/render
  ```
- Parse arguments after `--` using `sys.argv[sys.argv.index("--") + 1:]`
- Validate with focused scripts or tests before broad render runs

## Common Pitfalls

- Do not call `bpy.ops` outside the correct context — use context overrides or `temp_override()`
- Do not block the UI thread with long operations — use modal operators or background threads for heavy work
- Always check `bpy.app.version` when targeting multiple Blender versions