A minimal .NET 8 class library template for developing AutoCAD/Civil 3D plugins with debugging support in Visual Studio Code with Cursor. This is based on the AutoCAD .NET Wizards template written by Madhukar Moogala
https://www.youtube.com/watch?v=aX8c7zj9jGQ
- .NET 8.0 SDK or later
- AutoCAD 2025/2026
- Visual Studio Code with C# extension or Cursor IDE
- (Optional) Civil 3D 2025/2026 for Civil 3D development
You need to update the AutoCAD path:
<!-- 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
Open a terminal in the project directory and run:
dotnet build -c Debug -p:Platform=x64The DLL will be created in bin\Debug\AutoCADPlugin.dll
Note: The build may also create a copy in
bin\x64\Debug\, but use thebin\Debug\path for NETLOAD.
- Set breakpoints in
Commands.cs(e.g., in theHelloCommandmethod) - Start AutoCAD or Civil 3D manually
- In Cursor/VS Code, press
F5to attach debugger - Select the
acad.exeprocess when prompted - In AutoCAD, type
NETLOADand browse tobin\Debug\AutoCADPlugin.dll - Test with commands:
HELLOorDRAWCIRCLE
Your breakpoints will be hit!
The template includes a simple "Attach to AutoCAD" configuration in .vscode/launch.json that works for both AutoCAD and Civil 3D.
To enable Civil 3D development:
-
Uncomment the Civil 3D path in
AutoCADPlugin.csproj:<Civil3DPath>C:\Program Files\Autodesk\AutoCAD 2025\C3D</Civil3DPath>
-
Uncomment the Civil 3D references:
<Reference Include="AecBaseMgd"> <SpecificVersion>False</SpecificVersion> <HintPath>$(AutoCADPath)\ACA\AecBaseMgd.dll</HintPath> <Private>False</Private> </Reference> <Reference Include="AeccDbMgd"> <SpecificVersion>False</SpecificVersion> <HintPath>$(Civil3DPath)\AeccDbMgd.dll</HintPath> <Private>False</Private> </Reference>
-
Use Civil3D-Metric or Civil3D-Imperial launch profile when debugging
AutoCADPlugin/
├── AutoCADPlugin.csproj # Project configuration
├── Commands.cs # Sample AutoCAD commands
├── Properties/
│ └── launchSettings.json # Launch profiles
├── .vscode/
│ ├── launch.json # Debug configuration
│ └── tasks.json # Build tasks
└── README.md # This file
Create new command methods in Commands.cs or new class files:
[CommandMethod("MYCOMMAND")]
public void MyCommand()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
ed.WriteMessage("\nMy custom command executed!\n");
}- Update the
<AutoCADPath>in the project file - Ensure the AutoCAD .NET API version matches your target version
- Ensure AutoCAD path is correct in the project file
- Verify you're building for x64 platform
- Check that the AutoCAD version matches the referenced DLLs
- Ensure you're running in Debug configuration
- Check that the loaded DLL matches the one being debugged
- Try rebuilding the project and reloading in AutoCAD
- Ensure Civil 3D is installed
- Verify the Civil 3D path is correct
- Use the appropriate Civil 3D launch profile
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
João Martins in/jpornelas , Autodesk Platform Services