A minimal .NET 10 class library template for developing Revit plugins with Design Automation API support and debugging capabilities in Visual Studio Code with Cursor. This template is designed for automation workflows and cloud-based Revit processing using Autodesk Platform Services.
https://www.youtube.com/watch?v=hnjMVlEDR_k
- .NET 10.0 SDK or later
- Revit 2027 or later
- Visual Studio Code with C# extension or Cursor IDE
- (Optional) Design Automation Bridge for local testing
You need to update the Revit paths to match your installation:
<!-- Edit this path to match your Revit executable path -->
<RevitPath>C:\Program Files\Autodesk\Revit 2027</RevitPath>
<!-- Edit this path if you have Design Automation Bridge installed locally -->
<DesignAutomationBridgePath>C:\ProgramData\Autodesk\Revit\Addins\2027</DesignAutomationBridgePath>
<!-- Edit this path to match your Revit Addins path -->
<RevitAddinsPath>C:\ProgramData\Autodesk\Revit\Addins\2027</RevitAddinsPath>Common Revit installation path:
- Revit 2027:
C:\Program Files\Autodesk\Revit 2027
Open a terminal in the project directory and run:
dotnet build -c Debug -p:Platform=x64The DLL will be created in bin\Debug\RevitPlugin.dll
Note: The build process automatically updates the .addin file with the correct assembly path using
UpdateAddinPath.ps1.
- Set breakpoints in
Commands.cs(e.g., in theSampleMethod) - Copy the .addin file to your Revit Addins folder (automatic in Debug builds)
- Start Revit manually
- In Cursor/VS Code, press
F5to attach debugger - Select the
Revit.exeprocess when prompted - Your plugin will load automatically with Revit
Your breakpoints will be hit when the Design Automation events trigger!
This template is specifically designed for Design Automation workflows:
- Implements
IExternalDBApplicationfor database-level operations - No UI components (suitable for headless Revit execution)
- Includes
DesignAutomationBridgefor cloud automation support - Event-driven architecture with
DesignAutomationReadyEvent
The template includes debugging configuration in .vscode/launch.json that attaches to the Revit process.
RevitPlugin/
├── RevitPlugin.csproj # Project configuration
├── Commands.cs # Main plugin implementation
├── RevitPlugin.addin # Revit add-in manifest
├── UpdateAddinPath.ps1 # Build script for updating paths
├── package-bundle.ps1 # Packaging script for deployment
├── .vscode/
│ ├── launch.json # Debug configuration
│ └── tasks.json # Build tasks
├── .gitignore # Git ignore rules
├── LICENSE # License file
└── README.md # This file
Edit the HandleDesignAutomationReadyEvent method in Commands.cs:
private void HandleDesignAutomationReadyEvent(object? sender, DesignAutomationReadyEventArgs e)
{
LogTrace("Design Automation Ready event triggered...");
e.Succeeded = true;
// Add your custom logic here
ProcessRevitModel();
}
private void ProcessRevitModel()
{
// Access the Revit document
Document doc = e.DesignAutomationData.RevitDoc;
// Perform your operations
using (Transaction trans = new Transaction(doc, "My Operation"))
{
trans.Start();
// Your code here
trans.Commit();
}
}- Update the
<RevitPath>in the project file - Update the
<RevitAddinsPath>to match the version year - Ensure the
<TargetFramework>is compatible with your Revit version
- Ensure Revit path is correct in the project file
- Verify you're building for x64 platform
- Check that the Revit API version matches your Revit installation
- Ensure you're running in Debug configuration
- Verify the .addin file is in the correct Revit Addins folder
- Check that the assembly path in the .addin file is correct
- Try rebuilding the project
- Ensure DesignAutomationBridge.dll is referenced correctly
- Set
<Private>True</Private>for the bridge reference to include it in output - Verify the bridge path in the project file
- Check the Revit journal file for errors
- Verify the AddInId in the .addin file is unique
- Ensure the .addin file XML is valid
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