Skip to content

Nethrananda21/CADX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CADX — AI-Driven CAD Validation Agent

AI-powered design intelligence for early-stage CAD validation. Integrates with AutoCAD 2026 to automatically validate designs against building standards, highlight issues in real-time, suggest AI-powered fixes, and generate designs from natural language prompts.

Architecture

┌─────────────┐     COM (pyautocad)     ┌──────────────┐
│  AutoCAD    │◄────────────────────────│  Python      │
│  2026       │────DXF export──────────►│  Backend     │
│  ┌────────┐ │                         │  (FastAPI)   │
│  │ CADX   │ │◄──── WebBrowser ────────│  /panel      │
│  │ Sidebar│ │                         └──────┬───────┘
│  └────────┘ │               ┌────────────────┼────────────────┐
└─────────────┘               │                │                │
                        ┌─────▼─────┐   ┌──────▼──────┐  ┌─────▼─────┐
                        │  ezdxf    │   │  Ollama     │  │ Streamlit │
                        │  Analyzer │   │  Local LLM  │  │  Chat UI  │
                        └───────────┘   └─────────────┘  └───────────┘

Features

1. Automated Design Validation

  • 7 validation checks: unclosed polylines, overlapping geometry, room area minimums, wall thickness, layer naming, missing elements, dimension consistency
  • Issues highlighted directly in AutoCAD with color-coded markers (red = critical, yellow = warning, blue = info)
  • Configurable rules based on NBC India / IS standards

2. AI-Powered Fix Suggestions

  • Local LLM (DeepSeek-R1 / Qwen 3.5 via Ollama) analyzes each issue
  • Generates specific AutoCAD commands to fix problems
  • One-click auto-fix from the dashboard

3. Natural Language Design Generation

  • Type "design me a 3 floor duplex house" → full floor plan generated in AutoCAD
  • Template-assisted generation for reliable results
  • Rooms, walls, doors, windows, dimensions, and labels automatically placed

4. AI Sidebar Panel (Copilot-style)

  • Docked inside AutoCAD via .NET plugin (CADXPANEL command) — like GitHub Copilot in VS Code
  • Floating Python panel (panel.py) as zero-install alternative — always-on-top dark-themed window
  • Web panel at http://localhost:8001/panel — works in any browser
  • Chat with AI, validate, fix, and generate designs without leaving AutoCAD

5. Interactive Dashboard

  • Streamlit-based chat UI for AI interaction
  • Validation results with severity filtering
  • Per-issue fix buttons with command preview
  • HTML report generation and download

Quick Start

Prerequisites

  • AutoCAD 2026 (full desktop, running)
  • Python 3.11+
  • Ollama with models: deepseek-r1:14b, qwen3.5:9b

Setup

# 1. Install dependencies
cd CADX
pip install -r requirements.txt

# 2. Start Ollama (in separate terminal)
ollama serve

# 3. Start CADX
start.bat

Or manually:

# Terminal 1: Backend
uvicorn app:app --host 0.0.0.0 --port 8001

# Terminal 2: AI Panel (floating sidebar)
python panel.py

# Terminal 3: UI (optional — the panel replaces this)
streamlit run ui.py --server.port 8501 --server.headless true

AutoCAD Sidebar (Docked Plugin)

Option A — Python floating panel (recommended, no compilation):

python panel.py

A dark-themed AI panel appears on the right side of your screen.

Option B — .NET docked palette (true sidebar inside AutoCAD):

# Requires .NET 8 SDK: https://dotnet.microsoft.com/download/dotnet/8.0
cd plugin
build.bat

Then in AutoCAD:

NETLOAD → browse to build\CadxPlugin.dll
CADXPANEL

Option C — Browser panel: Open http://localhost:8001/panel in any browser.

AutoCAD Integration

Load the LISP helper in AutoCAD's command line:

(load "C:/Users/reddy/OneDrive/Desktop/CADX/cadx.lsp")

Available commands:

Command Description
CADX Validate current drawing
CADXFIX AI fix all issues
CADXDESIGN Generate design from prompt
CADXCLEAR Remove validation markers
CADXCHAT Ask the AI a question
CADXPANEL Open AI sidebar (.NET plugin)

API Endpoints

Method Endpoint Description
GET /status System status (AutoCAD, Ollama)
POST /validate Run validation on current drawing
GET /issues Get last validation results
POST /analyze AI analysis of issues
POST /fix Fix a specific issue
POST /fix-all Fix all issues
GET /panel AI sidebar panel (HTML)
POST /chat AI chat for CAD questions
POST /design Generate design from prompt
GET /report Download HTML validation report

Project Structure

CADX/
├── app.py                      # FastAPI backend
├── ui.py                       # Streamlit dashboard
├── panel.py                    # Floating AI sidebar (tkinter)
├── start.bat                   # One-click launcher
├── cadx.lsp                    # AutoLISP commands for AutoCAD
├── create_sample_dxf.py        # Generate test DXF with errors
├── core/
│   ├── __init__.py
│   ├── autocad_bridge.py       # COM automation bridge
│   ├── dxf_analyzer.py         # ezdxf validation engine (7 checks)
│   ├── llm_agent.py            # Ollama LLM integration
│   ├── design_generator.py     # NL → floor plan → AutoCAD
│   ├── rules.py                # Validation rule loader
│   └── report_generator.py     # HTML report generator
├── static/
│   └── panel.html              # Sidebar UI (served by FastAPI)
├── plugin/
│   ├── CadxPlugin.csproj       # .NET 8 project for AutoCAD palette
│   ├── CadxPlugin.cs           # C# plugin source (PaletteSet + WebBrowser)
│   └── build.bat               # Build script
├── rules/
│   ├── residential.json        # NBC India residential rules
│   └── general.json            # Generic CAD rules
├── reports/                    # Generated validation reports
└── sample_drawings/            # Test DXF files

Validation Rules (NBC India)

Rule Standard Value
Minimum room area NBC India 9.5 m²
Minimum wall thickness IS 1904 150 mm
Maximum stair riser IS 875 160 mm
Minimum door width NBC 750 mm
Minimum ceiling height NBC 2.7 m
Front setback Local bye-laws 4.5 m
Ventilation area NBC 10% of floor area

Tech Stack

  • Python 3.11+ — primary language
  • pyautocad + pywin32 — AutoCAD COM automation
  • ezdxf — DXF file parsing and analysis
  • Shapely — geometric operations (intersections, overlaps)
  • Ollama — local LLM inference (DeepSeek-R1, Qwen 3.5)
  • FastAPI — REST API backend
  • Streamlit — interactive dashboard UI

Demo

Test with sample drawing:

# Generate a DXF with intentional errors
python create_sample_dxf.py

# Validate it (API must be running)
curl -X POST http://localhost:8001/validate -H "Content-Type: application/json" -d "{\"dxf_path\": \"sample_drawings/test_house.dxf\", \"rules_file\": \"residential.json\"}"

Design generation:

curl -X POST http://localhost:8001/design -H "Content-Type: application/json" -d "{\"prompt\": \"design me a 3 floor duplex house\"}"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors