Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoCAD AI Agent Plugin

An intelligent, reasoning-capable AI assistant integrated directly into AutoCAD (2025/2026+) using the .NET 8.0 API and OpenAI-compatible LLM providers (Groq, OpenRouter, NVIDIA, or custom endpoints). This agent doesn't just chat; it has "Eyes" to see your design and "Hands" to modify it.

🚀 Overview

This plugin provides a WPF-based palette within AutoCAD that connects to a high-performance LLM. The agent is designed to be a Proactive Scout, meaning it automatically analyzes your drawing summary and current viewport as soon as you open it, allowing it to understand the context of your design immediately.


🛠 Setup & Installation

Prerequisites

  • AutoCAD 2025 or 2026 (or any version supporting .NET 8.0).
  • .NET 8.0 SDK installed on your machine.
  • At least one LLM API key:
    • Groq (GROQ_API_KEY)
    • OpenRouter (OPENROUTER_API_KEY)
    • NVIDIA (NVIDIA_API_KEY or NGC_API_KEY)

Steps

  1. Clone the Repository:

    git clone <your-repo-url>
    cd AutoCAD-AI-Agent
  2. Set Environment Variables: The plugin now supports multiple providers. Set these in Windows Environment Variables.

    Option A: NVIDIA (recommended if you already have an nvapi key)

    • AI_PROVIDER=nvidia
    • NVIDIA_API_KEY=your_nvidia_key
    • AI_MODEL=your_model_id (example: minimaxai/minimax-m1-80k if available for your account)

    Option B: OpenRouter

    • AI_PROVIDER=openrouter
    • OPENROUTER_API_KEY=your_openrouter_key
    • AI_MODEL=your_model_id (example: minimax/minimax-m1)
    • Optional: OPENROUTER_SITE_URL=https://your-site
    • Optional: OPENROUTER_APP_NAME=AutoCAD AI Agent

    Option C: Groq

    • AI_PROVIDER=groq
    • GROQ_API_KEY=your_groq_key
    • Optional: AI_MODEL=meta-llama/llama-4-scout-17b-16e-instruct

    Option D: Any OpenAI-compatible endpoint

    • AI_PROVIDER=custom
    • AI_API_KEY=your_key
    • AI_API_BASE_URL=https://your-endpoint/v1/chat/completions
    • AI_MODEL=your_model_id

    Notes:

    • AI_MODEL overrides provider defaults.
    • If AI_PROVIDER is omitted, provider auto-detection runs based on available keys.
  3. Build the Project:

    dotnet build MyBonusPlugin/MyBonusPlugin.csproj
  4. Load into AutoCAD:

    • Open AutoCAD.
    • Type NETLOAD in the command line.
    • Navigate to MyBonusPlugin/bin/x64/Debug/net8.0-windows/MyBonusPlugin.dll and select it.
  5. Launch the Agent:

    • Type AIAGENT in the command line to open the chat panel.

🧠 Core Concepts & Techniques

1. Chain of Thought (Reasoning Blocks)

The agent uses the Llama-4-Scout model, which generates internal reasoning before providing an answer.

  • Implementation: The plugin features a custom streaming parser that detects <think> and </think> tags in the API response.
  • UI: Reasoning is displayed in a collapsible "Reasoning..." dropdown (WPF Expander) to keep the chat clean while providing transparency.

2. The "Eyes & Hands" (Tool Calling)

The agent interacts with AutoCAD through a structured Tool Calling architecture. Instead of the AI writing code, it outputs JSON requests for specific tools.

  • Extraction Tools (Eyes): GetDrawingSummary, GetCurrentViewContext, and IdentifyBlocks serialize AutoCAD database objects into JSON context for the LLM.
  • Modification Tools (Hands): TransformEntity and UpdateEntityProperties allow the agent to move, rotate, scale, or change layers of objects based on their Handle.

3. Thread Marshalling (The Bridge)

AutoCAD's API is strictly single-threaded. LLM requests happen on background threads, which would normally crash AutoCAD.

  • The Fix: We use Application.DocumentManager.ExecuteInCommandContextAsync in the AIAgentOrchestrator to marshal requests back to the AutoCAD main thread safely before any database transaction begins.

4. Recursive Orchestration Loop

The agent is capable of multi-step reasoning.

  1. User asks: "Fix the alignment."
  2. LLM thinks and calls a tool to get coordinates.
  3. Plugin executes tool and feeds results back to LLM.
  4. LLM re-evaluates and calls a modification tool.
  5. Loop repeats until the task is complete (max 3 cycles).

🏗 Technology Stack

  • Language: C# 12 / .NET 8.0
  • UI Framework: WPF (hosted via ElementHost in a WinForms PaletteSet).
  • LLM Provider: OpenAI-compatible chat completion API (Groq/OpenRouter/NVIDIA/custom).
  • AutoCAD API: Autodesk.AutoCAD.DatabaseServices, Geometry, and EditorInput.

🚧 What's Next (Roadmap)

The agent is currently a powerful prototype, but the following features are yet to be implemented to make it fully autonomous:

  • [ ] Advanced Drawing Tools: Add DrawLine, DrawCircle, and CreateBlock tools so the agent can generate new designs from scratch.
  • [ ] 2D Parametric Tools: Implement SmartTrimExtend and ParametricOffset for complex architectural editing.
  • [ ] Design Validation Engine: A dedicated tool for the agent to compare the drawing against a provided "Rulebook" (e.g., "Check if all fire exits have 1.2m clearance").
  • [ ] 3D Support: Currently, the agent focuses on 2D coordinates. We need to implement 3D geometric reasoning for assembly designs.
  • [ ] Multi-modal Vision: Integration of screenshots (Vision LLM) to help the agent understand aesthetic layouts and crowded areas.

📄 License

This project is for educational and development purposes within the AutoCAD Agent Development course.

About

a module that integrates with CAD tools to analyse designs in real time and provide actionable insights

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages