CAD-Assistant is an experimental AutoCAD Electrical plugin that connects to the Perplexity AI API to provide an AI-powered assistant inside AutoCAD.
The plugin adds commands that let you chat with an AI model, automatically plan drawing actions in JSON, and execute those actions directly in the current drawing.
-
AI_CHAT
Free-form chat with the AI assistant about drawing, editing, and auditing tasks in AutoCAD Electrical. -
AI_DRAW
- Accepts a natural language request (in English).
- Sends context + request to the Perplexity API.
- Receives a JSON "plan" describing drawing/editing actions.
- Executes the plan in Model Space (lines, polylines, rectangles, circles, polygons, block inserts, moves, scales, rotates, erases, layer/property edits, etc.).
-
AI_AUDIT_LAYERS
Simple example of an automated audit that checks for required layers (e.g.,WIRE,TITLE) and reports visibility/plot settings.
The AI is instructed to return pure JSON with actions such as:
line,polyline,rectangle,circle,polygonmove,rotate,scale,eraseinsert_block(with attributes)change_layer(mass layer reassignment by filter)change_properties(color index, linetype, linetype scale by filter)
Each action may include a filter object to select entities by:
layertype(e.g.Line,Polyline,Circle)window:{"window":[[x1,y1],[x2,y2]]}for entities fully inside a rectangular windowcrossing:{"crossing":[[x1,y1],[x2,y2]]}for entities that touch or lie inside the window
The C# plugin parses this JSON and applies the requested transformations using AutoCAD .NET APIs.
- Windows with AutoCAD Electrical (tested with recent versions).
- .NET and Visual Studio 2022 (or compatible) to build the project.
- A Perplexity API key with access to the
sonarmodel.
The AutoCAD plugin uses the Perplexity pplx-api to generate chat responses and drawing plans.
You must configure an API key before running any AI_* commands.
There are two supported ways to provide the key:
Create a file named appsettings.local.json in the same folder as CADAssistant.dll
(for example, inside your .bundle Contents folder or the build bin\Debug\net8.0 folder).
{
"Perplexity": {
"ApiKey": "pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}Notes:
- The plugin looks for this file in the directory of the loaded
CADAssistant.dll, not in the AutoCAD executable directory. - The key must be a valid Perplexity API key (usually starts with
pplx-).
As an alternative, you can set the key as an environment variable on Windows: Before using the plugin:
- Replace
YOUR_API_KEY_HEREwith your own Perplexity API key. - Rebuild the project and reload the plugin in AutoCAD.
setx PPLX_API_KEY "pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"After setting it, restart AutoCAD so the new environment variable is visible to the process.
The plugin resolution order is:
- Try to read
Perplexity.ApiKeyfromappsettings.local.jsonnext toCADAssistant.dll. - If not found, read the
PPLX_API_KEYenvironment variable. - If neither is set, the plugin throws:
Perplexity API key not configured. Create appsettings.local.json with Perplexity.ApiKey next to CADAssistant.dll or set the PPLX_API_KEY environment variable.
- Open the solution in Visual Studio 2022.
- Make sure the target .NET Framework matches your AutoCAD version.
- Build the project (Build → Rebuild Solution).
- The resulting
.dllwill be created inbin/Debugorbin/Release.
- Copy the compiled
.dllto a folder of your choice (for example,C:\CADAssistant). - In AutoCAD, run the
NETLOADcommand and select the plugin.dll. - After loading, the command line should display the available commands:
AI_CHATAI_DRAWAI_AUDIT_LAYERS
You can then start experimenting by describing operations in English, such as:
Move all entities inside window from (0,0) to (200,100) to layer CENTER.Set all entities on layer 0 to color index 2, linetype CENTER, linetype scale 0.5.
Planned improvements include:
- Mirror and array actions (e.g.
mirror,array_linear). - Filters by geometric length/area (e.g. erase short segments, small hatches).
- Discipline-specific presets (electrical, mechanical, architectural).
Contributions, ideas, and issues are welcome via GitHub.