4 Dec 2025

Debugging AutoCAD and Civil 3D Plugins with Cursor: A Modern Developer Workflow

thumbnail

Introduction

If you ever found yourself developing a DLL bundle for AutoCAD Automation API, you probably came across this repo - It covers debugging locally with Visual Studio.

But the tooling landscape has changed. Today, AI assistants and modern IDEs like Cursor can do far more than autocomplete—they can help you "debug" too. 

In this post we’ll show you how to give AI access to your real-time debug feeds so it saves you time and mental-fatigue, during the toughest of C# debug sessions.

We already covered the steps for Revit here

Prerequisites

Before we begin, make sure you have:

  • AutoCAD or Civil 3D installed on your machine (2025 or later)
  • Cursor
  • .NET SDK (compatible with your AutoCAD/Civil 3D version)

Step-by-step video

How It Works

AutoCAD and Civil 3D plugins operate within the host application's process space. Unlike standalone applications, you can't just hit F5 and start debugging. Instead, you need to leverage process attachment debugging:

  1. Launch the CAD application - Start AutoCAD or Civil 3D normally
  2. Attach the debugger - Connect Cursor to the running acad.exe process
  3. Load your plugin - Use the NETLOAD command to load your compiled DLL
  4. Set breakpoints - Mark critical points in your code where you want to inspect execution
  5. Execute your command - Run your custom command in AutoCAD/Civil 3D
  6. Debug and iterate - Step through code, inspect variables, and fix issues on the fly

Setting Up Your Development Environment

1. Clone the Sample Repository

Start by grabbing the pre-configured sample project:

git clone https://github.com/autodesk-platform-services/acad-c3d-cursor-plugin-debug.git
cd acad-c3d-cursor-plugin-debug

This repository contains a simple "Hello World" plugin that demonstrates the debugging workflow for both AutoCAD and Civil 3D.

2. Configure the Launch Settings

Open .vscode/launch.json and you'll find configurations for both AutoCAD and Civil 3D:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to AutoCAD (with picker)",
            "type": "coreclr",
            "request": "attach",
            "justMyCode": false,
            "requireExactSource": false,
            "symbolOptions": {
                "searchPaths": ["${workspaceFolder}/bin/Debug"],
                "searchMicrosoftSymbolServer": false,
                "searchNuGetOrgSymbolServer": false
            },
            "preLaunchTask": "build"
        }
    ],
    "compounds": []
}

This configuration tells VS Code to:

  • Use the CoreCLR debugger (for .NET applications)
  • Attach to an existing process rather than launching a new one
  • Look for acad.exe (AutoCAD)

3. Update the AutoCAD paths to match your installation

You need to update the AutoCAD path:

In AutoCADPlugin.csproj (for assembly references):

<!-- Edit these paths to match your AutoCAD installation -->
<AutoCADPath>C:\Program Files\Autodesk\AutoCAD 2025</AutoCADPath>

<!-- For Civil 3D, uncomment and edit this path -->
<!-- <Civil3DPath>C:\Program Files\Autodesk\AutoCAD 2025\C3D</Civil3DPath> -->

Common AutoCAD installation paths:

  • AutoCAD 2026: C:\Program Files\Autodesk\AutoCAD 2026
  • AutoCAD 2025: C:\Program Files\Autodesk\AutoCAD 2025

For Civil 3D, you might also need Civil 3D-specific assemblies like AeccDbMgd.dll.

4. Build the Project

Compile the project using the .NET CLI or VS Code's build task:

dotnet build -c Debug -p:Platform=x64

The DLL will be created in bin\Debug\AutoCADPlugin.dll

Note: The build may also create a copy in bin\x64\Debug\, but use the bin\Debug\ path for NETLOAD.

Debugging in Action

Step 1: Launch AutoCAD/Civil 3D

Start AutoCAD /Civil 3D normally. Open any project or create a new one.

Step 2: Attach the Debugger

  1. Open your project in VS Code/Cursor
  2. Open the file containing your plugin code (e.g., Command.cs)
  3. Set a breakpoint by clicking in the gutter next to a line number (a red dot will appear)
  4. Press F5 or go to the Debug panel and click "Start Debugging"
  5. Manually select acad.exe to attach the AutoCAD process  

You should see the debug toolbar appear, indicating the debugger is connected.

Step 3: Trigger Your Plugin

In AutoCAD, type NETLOAD and browse to your dll.

When your code executes, AutoCAD will pause at your breakpoint, and VS Code will come to focus. Now you can:

  • Inspect variables by hovering over them or checking the Variables panel
  • Step through code using F10 (step over) or F11 (step into)
  • Evaluate expressions in the Debug Console
  • View the call stack to understand how you got to this point

Step 4: Make Changes and Reload

Here's where this workflow really shines. After debugging:

  1. Stop the debugger and close Autocad/Civil 3D
  2. Make your code changes
  3. Rebuild the project
  4. Open Autocad/Civil 3D again
  5. Attach the debugger again and test

When your code executes, AutoCAD will freeze (this is expected!), and Cursor will jump to focus with execution paused at your first breakpoint.

Common Issues and Solutions

"Cannot attach to process"

Problem: Cursor can't find or attach to the CAD process.

Solutions:

  • Verify AutoCAD/Civil 3D is actually running
  • Run Cursor as Administrator (required for some system configurations)

Breakpoints Show as Hollow/Unverified

Problem: Breakpoints appear as hollow circles and don't trigger.

Solutions:

  • Build with Debug configuration, not Release
  • Verify the DLL loaded by AutoCAD matches your build output path
  • Check that you're attaching to the correct process
  • Ensure PDB (debug symbol) files are in the same directory as your DLL

Changes Don't Take Effect

Problem: Code changes don't appear when you test.

Solutions:

  • Some changes (like adding new commands) require AutoCAD restart
  • Verify you're loading the correct DLL path (not an old copy)
  • Check that the build succeeded without errors

DLL File Locked

Problem: Can't rebuild because the DLL is in use.

Solutions:

  • Close AutoCAD completely if the lock persists
  • Configure your build to output to a different directory each time (advanced)

Conclusion

Setting up a proper debugging workflow for AutoCAD and Civil 3D plugins transforms development from a tedious trial-and-error process into a systematic, efficient practice. The ability to pause execution, inspect the AutoCAD object model in real-time, and iterate quickly makes you a more productive developer and results in higher-quality plugins.

This setup is especially powerful when combined with an AI native tools like Cursor, which can assist with code generation while you use the debugger to verify behavior and catch edge cases.

Whether you're building simple automation tools or complex Civil 3D integrations, take the time to master this debugging workflow. Your productivity will increase, and you'll spend less time guessing and more time building.

Happy debugging! 

SOURCE

Related Article