Skip to content

GadatheGod/FreeCAD-AI-Agent-Windows-Linux

Repository files navigation

FreeCAD AI Agent

Chat with FreeCAD in natural language. Powered by Ollama (Qwen2.5-Coder 32B) + AnythingLLM RAG.

You: "Create a gear with 20 teeth, 50mm diameter"
  → RAG fetches FreeCAD API docs
  → Qwen2.5-Coder generates Python code
  → Code executes live in FreeCAD
  → 3D model appears ✅

Requirements

  • Windows 10/11 or Ubuntu/Debian Linux
  • NVIDIA RTX 3090 (24GB VRAM)
  • FreeCAD installed
  • Python 3.10+
  • Internet connection (for first-time model download ~20GB)

Quick Start

Windows

# 1. Unzip and open folder in PowerShell
cd freecad-ai-agent

# 2. Run one-shot setup
powershell -ExecutionPolicy Bypass -File setup.ps1

Linux

# 1. Clone / unzip this repo
cd freecad-ai-agent

# 2. Run one-shot setup (installs everything)
chmod +x setup.sh
./setup.sh

# 3. Configure AnythingLLM
#    ~/AnythingLLM.AppImage
#    Settings → LLM: Ollama → qwen2.5-coder:32b
#    Settings → Embeddings: Ollama → nomic-embed-text
#    Create workspace: "freecad"
#    Settings → Get API key → copy it

# 4. Add your API key
cp config.example.json config.json
nano config.json   # paste AnythingLLM API key

# 5. Scrape + index FreeCAD docs
source venv/bin/activate
python scrape_freecad.py
#    Then in AnythingLLM → workspace → Add Data → Local Folder → freecad_docs/

# 6. Load FreeCAD macro
#    Open FreeCAD
#    Macro → Macros → Browse → macros/ai_listener.py → Execute
#    (Console should say: AI Agent Listener started on localhost:9999)

# 7. Start the agent
python freecad_agent.py

Usage

You: create a 100x50x30mm box
You: add a 15mm cylindrical hole through the center vertically
You: fillet all top edges with 3mm radius
You: export to /home/user/model.step
You: make the box twice as tall

Commands

Command Action
exit Quit the agent
clear Clear conversation history
noexec Toggle auto-execute on/off

Architecture

You (chat)
    ↓
freecad_agent.py
    ├── AnythingLLM (RAG) ← FreeCAD Wiki + GitHub docs
    ├── Ollama (Qwen2.5-Coder 32B) ← RTX 3090
    └── FreeCAD socket bridge (port 9999)
              ↓
         ai_listener.py (FreeCAD macro)
              ↓
         FreeCAD Python API
              ↓
         3D Model updates live

Troubleshooting

Ollama not running:

ollama serve

Model not found:

ollama pull qwen2.5-coder:32b

FreeCAD not connected:

  • Open FreeCAD
  • Macro → Macros → ai_listener.py → Execute
  • Check FreeCAD console for "AI Agent Listener started"

AnythingLLM API key:

  • Open AnythingLLM → Settings → API Keys → Generate
  • Paste into config.json

File Structure

freecad-ai-agent/
├── setup.sh              # one-shot installer
├── freecad_agent.py      # main agent (run this)
├── scrape_freecad.py     # FreeCAD doc scraper
├── config.example.json   # config template
├── config.json           # your config (gitignored)
├── requirements.txt      # Python dependencies
├── freecad_docs/         # scraped docs (auto-created)
└── macros/
    └── ai_listener.py    # FreeCAD macro

About

FreeCAD-Bridge-Ollama is a local AI-powered CAD assistant that converts natural language commands into executable FreeCAD Python code. Type "make cube 50mm" in a sleek web chat interface, and any AI model (running via Ollama) instantly generates precise FreeCAD API scripts. A custom TCP socket server executes code in FreeCAD,creating 3D geometry.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors