-
Notifications
You must be signed in to change notification settings - Fork 0
Hosts AutoCAD
AutoCAD (and its vertical products: Civil 3D, Plant 3D, Architecture, MEP, Electrical, Mechanical, Map 3D) is a fully supported host in RevitDevTool v3.0.
The AcadDevTool add-in loads in all AutoCAD-family products:
| Product | Registry Detection | Pipe Prefix |
|---|---|---|
| AutoCAD | ACAD-*001 |
AutoCad |
| Civil 3D | ACAD-*003 |
Civil3D |
| Plant 3D | ACAD-*016 |
Plant3D |
| AutoCAD Architecture | ACAD-*004 |
Product-specific |
| AutoCAD MEP | ACAD-*005 |
Product-specific |
| AutoCAD Electrical | ACAD-*006 |
Product-specific |
| AutoCAD Mechanical | ACAD-*012 |
Product-specific |
| AutoCAD Map 3D | ACAD-*014 |
Product-specific |
| Feature | Revit | AutoCAD Family | Notes |
|---|---|---|---|
| Python 3.13 | Full | Full | Same PythonNet/Pixi environment |
| PEP 723 dependencies | Full | Full | Auto-install via Pixi |
| VSCode debugging | Full | Full | debugpy integration |
| C# / Assembly execution | Full | Full |
IExternalCommand discovery |
| F# scripts | Full | Full | Roslyn-based |
| Logging panel | Full | Full | Multi-sink, color keywords |
| MCP tools (standalone) | Full | Full | Host discovery, launch, open model |
| MCP tools (in-host) | Full | Full |
execute_csharp_code, open_document
|
| PyTest bridge | Full | Full | Multi-host client plugin |
| DirectContext3D visualization | Full | N/A | Revit-only rendering API |
| Geometry trace interception | Full | N/A | Revit-only log routing |
| Command Browser | Full | Not yet | Planned |
Revit injects __revit__ (a UIApplication instance) into the Python scope. AutoCAD does not — instead use the static Application class:
from Autodesk.AutoCAD.ApplicationServices.Core import Application
doc = Application.DocumentManager.MdiActiveDocument
db = doc.Database
editor = doc.EditorAutoCAD uses TransactionManager.StartTransaction() (similar to Revit but different API):
from Autodesk.AutoCAD.DatabaseServices import OpenMode
tr = db.TransactionManager.StartTransaction()
try:
bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
# ... work with database objects ...
tr.Commit()
except Exception:
tr.Abort()
raise
finally:
tr.Dispose()Both Revit and AutoCAD hosts use sys.__devtool__ as the unified Python state attribute for the DevTools platform.
Create a .script.py file with PEP 723 dependencies:
# /// script
# dependencies = ["tabulate>=0.9"]
# ///
from Autodesk.AutoCAD.ApplicationServices.Core import Application
from Autodesk.AutoCAD.DatabaseServices import LayerTable, OpenMode
from tabulate import tabulate
doc = Application.DocumentManager.MdiActiveDocument
db = doc.Database
with doc.LockDocument():
tr = db.TransactionManager.StartTransaction()
try:
lt = tr.GetObject(db.LayerTableId, OpenMode.ForRead)
rows = []
for oid in lt:
ltr = tr.GetObject(oid, OpenMode.ForRead)
rows.append([ltr.Name, "On" if not ltr.IsOff else "Off"])
tr.Commit()
finally:
tr.Dispose()
print(tabulate(rows, headers=["Layer", "Status"]))See PyTest Bridge for multi-host testing setup. Configure pyproject.toml:
[tool.pytest.ini_options]
host_name = "autocad"
host_version = "2026"The standalone MCP server auto-discovers running AutoCAD instances. All built-in tools work with AutoCAD hosts:
# AI assistant can:
- List running AutoCAD instances
- Launch a new AutoCAD instance
- Open a DWG file
- Execute C# code in AutoCAD
- Civil 3D Features — Civil 3D-specific APIs and workflows
- Host Support — full feature matrix
- AutoCAD C# Demo — C# example
- Run Code Overview
- Modern Python Scripting
- Python Debugging
- Python Ecosystems
- RevitDevTool And pyRevit
- Python Stub Generation
- Run .NET Add-ins
- Scripting Runtimes