mcpField
A
autocad-drafting

autocad-drafting

github.com/puran-waterDesign & UI155 installsUpdated 33w ago
Repository

About autocad-drafting

autocad-drafting is an agent skill that guides CAD drawing tasks through autocad-mcp. It provides a staged drafting workflow, tool-selection advice, and safeguards for sequential IPC calls and bounded AutoLISP batches.

Key features

  1. 01Follow a staged drawing workflow
  2. 02Choose tools by drawing task
  3. 03Batch bulk work with execute_lisp
  4. 04Create text and arrows with entmake
  5. 05Verify drawings with screenshots
  6. 06Avoid IPC races and timeouts

Use cases

  1. 01Draft equipment layouts and site boundaries
  2. 02Add labels, dimensions, and title blocks
  3. 03Create piping flow arrows
  4. 04Inspect and iterate on a drawing

MCP support

The skill guides use of the autocad-mcp MCP server, including its system, entity, annotation, view, drawing, and related tools. It specifies sequential tool calls and bounded execute_lisp batches.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/puran-water/autocad-drafting --skill autocad-drafting

After installing, type/autocad-draftingin Claude Code to confirm it loaded.

Bundled filesNOTICE.mdreferences/tool-reference.md

Details

From the project README

AutoCAD Drafting via autocad-mcp

Critical Rules

NEVER call multiple autocad-mcp tools in parallel. The File IPC backend is single-threaded. Concurrent calls race at the IPC level and corrupt the dispatch, triggering APPLOAD dialogs and timeouts. Always call tools sequentially.

Prefer execute_lisp for bulk operations. A single execute_lisp call with 5-7 (command ...) invocations is faster and more reliable than 5-7 separate tool calls (each incurs ~1-2s IPC round-trip overhead).

Keep execute_lisp batches under ~500 lines / 7 commands. Exceeding the IPC timeout (default 10s, configurable via AUTOCAD_MCP_IPC_TIMEOUT) leaves AutoCAD stuck in a pending command state. Smaller batches are safer.

Drawing Workflow

Follow this sequence for any drawing task:

  1. Verify connection - system(operation="status") to confirm backend
  2. Set up layers - Create all layers before any geometry
  3. Create geometry - Equipment outlines, site boundaries, piping
  4. Add annotations - Equipment tags, text labels, notes
  5. Add dimensions - Linear, aligned, angular
  6. Title block - Border, title text, project info
  7. Screenshot QA - view(operation="get_screenshot") to verify, iterate

execute_lisp Patterns

Use system(operation="execute_lisp", data={"code": "..."}) for bulk work.

Layer setup batch:

(progn
  (if (not (tblsearch "LAYER" "EQUIPMENT"))
    (command "_.-LAYER" "_NEW" "EQUIPMENT" "_COLOR" "cyan" "EQUIPMENT" ""))
  (if (not (tblsearch "LAYER" "PIPING"))
    (command "_.-LAYER" "_NEW" "PIPING" "_COLOR" "blue" "PIPING" ""))
  "layers created"
)

Equipment placement batch (5-7 items max):

(progn
  (setvar "CLAYER" "EQUIPMENT")
  (command "_RECTANG" (list 5 20 0) (list 15 30 0))
  (command "_CIRCLE" (list 40 25 0) 8)
  (command "_RECTANG" (list 55 18 0) (list 70 32 0))
  "equipment placed"
)

Text annotations — use entmake, NOT (command "_TEXT" ...):

(command "_TEXT" "J" "ML" ...) has unreliable prompt sequences that leave AutoCAD in an input-waiting state, blocking subsequent dispatches. Always use entmake for text:

(progn
  (setvar "CLAYER" "ANNOTATION")
  ;; Helper: tag + description at (x, y) with height ht
  (defun make-tag (x y tag desc ht / )
    (entmake (list '(0 . "TEXT") (cons 10 (list x y 0)) (cons 40 ht) (cons 1 tag)
      (cons 72 1) (cons 11 (list x y 0)) '(8 . "ANNOTATION")))
    (entmake (list '(0 . "TEXT") (cons 10 (list x (- y (* ht 1.3)) 0))
      (cons 40 (* ht 0.7)) (cons 1 desc) (cons 72 1)
      (cons 11 (list x (- y (* ht 1.3)) 0)) '(8 . "ANNOTATION")))
  )
  (make-tag 10 25 "P-101" "PUMP STATION" 1.5)
  (make-tag 40 25 "CL-201" "CLARIFIER" 1.5)
  "annotations placed"
)

Flow arrows — use entmake LWPOLYLINE, NOT (command "_SOLID" ...):

_SOLID has the same prompt-sequence problem as _TEXT. Use closed LWPOLYLINE:

(progn
  (setvar "CLAYER" "PIPING")
  ;; Helper: arrow at (x,y) pointing in direction "R"/"L"/"D"/"U"
  (defun make-arrow (x y dir / p1 p2 p3)
    (cond
      ((= dir "R") (setq p1 (list x (+ y 0.5)) p2 (list (+ x 2) y) p3 (list x (- y 0.5))))
      ((= dir "D") (setq p1 (list (- x 0.5) y) p2 (list x (- y 2)) p3 (list (+ x 0.5) y)))
      ((= dir "L") (setq p1 (list x (- y 0.5)) p2 (list (- x 2) y) p3 (list x (+ y 0.5))))
      ((= dir "U") (setq p1 (list (+ x 0.5) y) p2 (list x (+ y 2)) p3 (list (- x 0.5) y)))
    )
    (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(8 . "PIPING")
      '(100 . "AcDbPolyline") '(90 . 3) '(70 . 1)
      (cons 10 p1) (cons 10 p2) (cons 10 p3)))
  )
  (make-arrow 16 25 "R")
  "arrow placed"
)

Tool Selection Guide

TaskToolNotes
Single entityentity(operation="create_*")Use for one-off entities
Bulk entities (3+)system(operation="execute_lisp")Batch in (progn ...)
Layer operationslayer(operation="*") or execute_lispEither works; batch if 3+
Dimensionsannotation(operation="create_dimension_*")One at a time is fine
Screenshotview(operation="get_screenshot")Returns PNG image
Undo mistakedrawing(operation="undo")Single undo step
Savedrawing(operation="save")Add data: {path} for save-as
Open filedrawing(operation="open", data={"path": "..."})DWG or DXF
P&ID symbolspid(operation="insert_*")Requires CTO library

Reload Dispatcher Without Human Intervention

If mcp_dispatch.lsp needs reloading after an update:

system(operation="execute_lisp", data={"code":
  "(progn (setvar \"SECURELOAD\" 0) (load \"C:/Users/hvksh/mcp-servers/autocad-mcp/lisp-code/mcp_dispatch.lsp\") (setvar \"SECURELOAD\" 1) \"dispatch reloaded\")"
})

Pitfalls and Mitigations

PitfallCauseMitigation
APPLOAD dialogParallel tool calls interleave PostMessageW keystrokesNever call tools in parallel
IPC timeoutBatch too large or command awaiting inputKeep batches under 7 commands
Stuck commandPrevious timeout left AutoCAD in command promptServer sends ESC prefix automatically (v3.1+)
SECURELOAD dialog(load) on untrusted pathServer suppresses automatically (v3.1+)
drawing.create resetsErases all + purges current drawing (not _.NEW)LISP namespace preserved; no new tab
Non-ASCII crashLISP writes cp1252, Python reads UTF-8Server falls back to cp1252 (v3.1+)
drawing.save ignores pathOld LISP did QSAVE alwaysFixed in v3.1 — uses SAVEAS when path given
TEXT/SOLID timeout(command "_TEXT" "J" "ML" ...) and _SOLID have unreliable prompt sequencesUse entmake instead — no command-line interaction

Backend Differences

FeatureFile IPC (live AutoCAD)ezdxf (headless)
execute_lispYesNot supported
undo / redoYesNot supported
plot_pdfYesNot supported
offset / fillet / chamferYesNot supported
ScreenshotWin32 PrintWindowmatplotlib render
PlatformWindows onlyAny (Linux/Mac/WSL)

Reference

For detailed tool operations, see tool-reference.md.

Comments

Markdown supported