Skip to content

rt23-dev/blenderLLM

Repository files navigation

LLM Blender Assistant

A powerful Blender addon that uses Claude AI to generate 3D models from text prompts. The addon features a multi-agent system where one agent interprets and plans your request, and another generates executable Blender Python code.

Features

  • Two-Agent System:

    • Planning Agent: Interprets your prompt and breaks it down into actionable steps
    • Code Generation Agent: Generates clean, executable Blender Python code
  • Multi-threaded: Non-blocking async operations keep Blender responsive

  • Real-time Status: See what's happening at each stage

  • Error Handling: Comprehensive error reporting and recovery

  • Claude Integration: Uses Anthropic's Claude API for intelligent code generation

Installation

Prerequisites

  1. Anthropic API Key: Get your API key from Anthropic Console
  2. httpx Library: The addon requires the httpx library in Blender's Python environment
  3. h2 Library (Optional): Installing h2 enables HTTP/2 support for better performance, but the addon will work without it using HTTP/1.1

Installing httpx (and optionally h2) in Blender

Blender uses its own Python interpreter. To install httpx:

  1. Find Blender's Python executable:

    • Windows: Usually in C:\Program Files\Blender Foundation\Blender [version]\[version]\python\bin\python.exe
    • macOS: Right-click Blender.app → Show Package Contents → Contents/Resources/[version]/python/bin/python3
    • Linux: Usually /usr/bin/blender or check with which blender
  2. Install httpx (required):

    # Windows
    "C:\Program Files\Blender Foundation\Blender 3.6\3.6\python\bin\python.exe" -m pip install httpx
    
    # macOS/Linux
    /path/to/blender/python/bin/python3 -m pip install httpx
  3. Install h2 (optional, for HTTP/2 support):

    # Windows
    "C:\Program Files\Blender Foundation\Blender 3.6\3.6\python\bin\python.exe" -m pip install h2
    
    # macOS/Linux
    /path/to/blender/python/bin/python3 -m pip install h2

    Or use Blender's bundled pip:

    # Required
    blender --python-expr "import subprocess; subprocess.check_call(['python', '-m', 'pip', 'install', 'httpx'])"
    
    # Optional (for better performance)
    blender --python-expr "import subprocess; subprocess.check_call(['python', '-m', 'pip', 'install', 'h2'])"

Installing the Addon

  1. Copy the blender_addon folder to Blender's addons directory:

    • Windows: %APPDATA%\Blender Foundation\Blender\[version]\scripts\addons\
    • macOS: ~/Library/Application Support/Blender/[version]/scripts/addons/
    • Linux: ~/.config/blender/[version]/scripts/addons/
  2. Or install via Blender:

    • Edit → Preferences → Add-ons → Install...
    • Select the blender_addon folder
  3. Enable the addon in Preferences → Add-ons → Search "LLM Blender Assistant"

Configuration

  1. Open Blender Preferences (Edit → Preferences)
  2. Go to Add-ons → LLM Blender Assistant
  3. Click on the addon name to expand settings
  4. Enter your Anthropic API Key
  5. (Optional) Change the Claude model (default: claude-3-5-sonnet-20241022)

Usage

  1. Open Blender
  2. In the 3D Viewport, open the sidebar (press N if hidden)
  3. Go to the "LLM Assistant" tab
  4. Enter your prompt describing what you want to create
    • Example: "Create a red cube with a metallic material"
    • Example: "Make a sphere with a glass material and add a light"
    • Example: "Create a simple house with a roof, walls, and a door"
  5. Click "Generate Model"
  6. Watch the status as the agents work:
    • Planning: The planning agent analyzes your request
    • Generating: The code agent creates Blender Python code
    • Executing: The code runs in Blender
    • Complete: Your model is ready!

How It Works

  1. User Input: You type a natural language prompt
  2. Planning Agent: Claude analyzes the prompt and creates a structured plan with steps
  3. Code Generation Agent: Claude generates executable Blender Python code based on the plan
  4. Execution: The code runs safely in Blender's Python environment
  5. Result: Your 3D model appears in the viewport!

Example Prompts

  • "Create a simple cube with a red material"
  • "Make a sphere with a glass material"
  • "Create a torus with a metallic blue material"
  • "Make a cylinder and add a subdivision surface modifier"
  • "Create a simple house with walls, roof, and a door"
  • "Generate a low-poly tree"
  • "Create a donut with icing"

Troubleshooting

"No API key configured"

  • Set your Anthropic API key in Addon Preferences

"ModuleNotFoundError: No module named 'httpx'"

  • Install httpx in Blender's Python environment (see Installation section)

"h2 packet not installed" (if you see this error)

  • The addon now automatically falls back to HTTP/1.1 if h2 is not installed
  • If you want HTTP/2 support for better performance, install h2: python -m pip install h2

Code execution errors

  • Check the error message in the status panel
  • Try rephrasing your prompt more clearly
  • Some complex requests may need multiple attempts

Addon not appearing

  • Make sure the addon is enabled in Preferences → Add-ons
  • Check that all files are in the correct location
  • Restart Blender

Technical Details

  • Python Version: Compatible with Blender 3.0+ (Python 3.9+)
  • API: Uses Anthropic Claude API (Messages API)
  • Threading: Uses asyncio and threading for non-blocking operations
  • Code Execution: Safe execution environment with proper error handling

License

This addon is provided as-is for educational and development purposes.

Contributing

Feel free to improve the prompts, add features, or fix bugs!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages