What you can automate
| Area | Examples |
|---|---|
| Geometry | Create and edit lines, polylines, arcs, hatches, 3D solids |
| Blocks and attributes | Insert blocks, read and update attributes, dynamic block properties |
| Drawing settings | Layers, text styles, dimension styles, linetypes |
| Layouts and plotting | Create layouts and viewports, plot to PDF, page setups |
| References | Attach, reload, bind and repath xrefs and images |
| Tables and fields | Generate schedules and BOM tables |
| Events | React to commands, object changes, document open and save |
| User interface | Commands, ribbon tabs, palettes, dialogs, context menus |
| Batch processing | Open drawings in memory (side databases) without displaying them |
| Integration | Excel, SQL databases, REST APIs, ERP and PDM systems |
A simple command
[CommandMethod("EM_UPDATETITLE")]
public void UpdateTitle()
{
var doc = Application.DocumentManager.MdiActiveDocument;
using var tr = doc.Database.TransactionManager.StartTransaction();
var bt = (BlockTable)tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead);
foreach (ObjectId btrId in bt)
{
var btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
if (!btr.IsLayout) continue;
foreach (ObjectId id in btr)
if (tr.GetObject(id, OpenMode.ForRead) is BlockReference br
&& br.Name == "TITLE_A1")
SetAttribute(tr, br, "PROJECT", "ENG-2026-014");
}
tr.Commit();
}
Batch processing with side databases
Drawings can be read into a Database object without opening them in the editor. This is dramatically faster for batch updates across hundreds of files, such as title block changes or layer cleanup.
using var db = new Database(false, true);
db.ReadDwgFile(path, FileOpenMode.OpenForReadAndWriteNoShare, true, null);
// ... modify objects in a transaction ...
db.SaveAs(path, DwgVersion.Current);
User interfaces
Add-ins can add ribbon tabs, dockable palettes with WPF or WinForms, and custom dialogs, giving engineers a polished tool that feels part of AutoCAD.
Things to know
- AutoCAD 2025 and later use .NET 8; earlier versions use .NET Framework 4.x.
- Always use transactions and dispose objects properly.
- Lock documents when modifying from palettes or modeless dialogs.
- The .NET API also works in verticals like Civil 3D, Plant 3D and MEP, which add their own .NET APIs.
If a task is done repeatedly in AutoCAD, the .NET API can almost certainly automate it.