Skip to main content
Glama
AutoCAD Workflow

AutoCAD Workflow

by zzy-super

dsh-autocad-toolkit

用聊天驱动 AutoCAD 2025,按 GB 制图标准干活,并用结构判决证明改对了——不是截图看一眼,而是「移动 +100.000 mm」这种精确结论。

⚠️ 先读 DISCLAIMER.md(免责声明)。 这套工具会真实修改、删除图纸实体,批量写入会覆盖文件,autocad_run 能执行任意 AutoLISP。 请只在已备份、可丢弃的图纸上试;不同意免责声明请勿使用。

它是什么

一个 DeepSeek Harness 插件。装好后 DSH 里多出 mcp__autocadworkflow__* 一组工具,模型可以像操作数据一样操作 AutoCAD:

环节

工具

做什么

手

autocad_draw / autocad_symbol / autocad_connect / autocad_annotate

装 GB 标准、画图框标题栏、摆符号、端口正交连线、标注

眼

autocad_inspect / autocad_recognize / autocad_capture

handle 级几何、结构识别与异常清单、窗口截图 + OCR

改

autocad_edit / autocad_layer / autocad_attrib / autocad_table

按 handle 移动/复制/阵列/旋转/缩放/镜像/偏移/删除,改图层、写属性、出真表格

验

autocad_sentry

结构快照 → 改动 → verdict 对比(9 种判决 + 退出码)

批量/交付

autocad_headless / autocad_plot / autocad_run / autocad_watch

无头 lint/batch、出 PDF、任意 LISP、图纸内规则反应器

它按 GB 习惯做事:机械/电气/工艺三专业图层、25 mm 装订边图框与 180×56 标题栏、52 个符号、端口到端口的正交连线,以及能被 ATTEDIT 和数据提取认出来的块属性。

Related MCP server: AutoCAD MCP Pro

环境要求

依赖

说明

Windows 10 / 11

COM + AutoLISP,仅 Windows

AutoCAD 2025

正版授权;其他版本未验证

Python 3.10+

需要 pywin32(COM),安装器会检测并提示

DeepSeek Harness

桌面版,profile 可用(默认 desktop)

AutoCAD 装在非默认路径也可以:安装器会搜 Program Files\Autodesk、D:\Program Files\Autodesk,也可以 -AcadExe 指定,或设 DSH_ACAD_EXE。

安装(三步)

  1. 克隆到任意目录(建议无空格/中文):

    git clone https://github.com/zzy-super/dsh-autocad-toolkit.git D:\tools\dsh-autocad-toolkit
  2. 运行安装脚本(渲染路径 + 注册到 profile,会先备份 package.json):

    powershell -ExecutionPolicy Bypass -File D:\tools\dsh-autocad-toolkit\install.ps1
    # 可选:-ProfileName <名字>  -Python <python.exe>  -AcadExe <acad.exe>  -DryRun
  3. 重启 DeepSeek Harness,新会话说一句「看看 AutoCAD 的状态」(脚本会调 autocad_app)。

自检与卸载:

powershell -ExecutionPolicy Bypass -File .\verify.ps1        # 静态检查
powershell -ExecutionPolicy Bypass -File .\verify.ps1 -Live  # 起一次 MCP 服务器,确认 18 个工具
powershell -ExecutionPolicy Bypass -File .\uninstall.ps1     # 从 profile 移除(文件保留)

手动安装也可以:把 cordis.patch.yml.tmpl 复制成 cordis.patch.yml,填好 {{PYTHON}} / {{INSTALL_DIR}} / {{ACAD_EXE}},再在 DSH「设置 → 插件」里从本地目录添加。

5 分钟上手

打开一张 demo 图纸,然后:

你:  在 demo 图纸里画一个 A3 图框,机械专业,标题写"换热站流程图"。

模型:autocad_app  action=open path=...\demo\dsh-demo-mech.dwg
       autocad_draw action=both discipline=mech size=A3 fields={...}
       autocad_symbol action=insert name=vessel x=60 y=140 tag=V-101
       autocad_symbol action=insert name=pump_centrifugal x=60 y=60 tag=P-101
       autocad_connect items=[{from:{tag:P-101,port:r}, to:{tag:V-101,port:l}}]
       autocad_sentry action=snapshot label=base

改完验收(结构级,不靠眼睛):

autocad_edit   op=move handles=["2F"] delta=[100,0]
autocad_sentry action=verdict label=base
→ GEOMETRY_MOVED (+100.000 mm)   verdict=2

出图与批量:

autocad_plot path=D:\out\sheet.pdf paper="ISO_A3_(420.00_x_297.00_MM)"
autocad_headless mode=read path=D:\dwg        # lint 一整个目录
autocad_headless mode=write path=D:\dwg lisp="(progn ...)"   # 写副本,原件不动

18 个 MCP 工具

工具

作用

autocad_app

会话:状态 / 启动 acad.exe 并挂 COM / list / open / new / save / saveas / close

autocad_draw

GB 标准(三专业图层、文字/标注样式、线型)+ A0–A4 图框与标题栏

autocad_symbol

52 个符号的插入(带端口与 XDATA)、符号表排版

autocad_connect

端口到端口正交路由(tag+port 或 point+dir)

autocad_annotate

尺寸 / 半径 / 直径 / 角度 / 引线 / 气泡 / 中心线 / 文字

autocad_table

真 ACAD_TABLE(BOM / 设备表 / 材料表),可双击编辑、可数据提取

autocad_attrib

块属性 get/table/set,直接喂给 autocad_table

autocad_block

块定义列表 / 原地重定义(保留位置比例旋转)/ 清理

autocad_inspect

handle 级几何(线/圆/弧/文字/块),按窗口或点附近选择

autocad_recognize

结构识别:census、符号与标签配对、异常清单、连通性检查

autocad_edit

move / copy / array / rotate / scale / mirror / erase / offset / setprop / settext

autocad_layer

建 / 设 / 改名 / 移动实体 / 删

autocad_capture

PrintWindow 截图(不抢焦点)+ bbox 放大 + OCR + 像素门 diff

autocad_sentry

结构快照 / 判决 / 列表,9 种判决与 0/2/3 退出码

autocad_run

逃生口:任意 AutoLISP 或命令(进程内求值 2.7 ms)

autocad_headless

accoreconsole:lint 只读体检、batch 写副本,约 0.5 s/图

autocad_plot

DWG To PDF,强制 BACKGROUNDPLOT=0,校验文件头与大小

autocad_watch

AutoLISP 反应器 + 规则库(5 条内置,最多 12 条),跑在图纸事件循环里

符号库

52 个,autocad_symbol action=list 可以看到全部:

专业

数量

例子

机械 mech

13

表面粗糙度、基准符号、剖切符号、角焊缝、键槽、外螺纹、滚动轴承

电气 elec

21

断路器、常开/常闭触点、线圈、熔断器、变压器、电动机、三极管、端子

工艺 process

18

闸阀/球阀/蝶阀/止回阀/调节阀/安全阀、离心泵、换热器、塔器、容器、仪表

每个符号带 端口定义(autocad_connect 用)和 XDATA(autocad_recognize 读身份,不靠邻近文字猜标签)。

能力清单

  • GB 图纸标准:三专业图层、文字样式、DSH_DIM 标注样式、线型;A0–A4 图框 + 180×56 标题栏并可填字段

  • 端口路由:从端口方向进出,stub 不超过跨距 1/3,布线不会贴歪

  • 真表格:ACAD_TABLE 可双击编辑,数据提取能读到;API 被拒时退回画线表格

  • 块属性:位号/管号/型号写在属性里,ATTEDIT 和 BOM 都能看见

  • 块生命周期:块名带内容哈希,重定义不会污染旧图

  • 结构判决:NO_CHANGE / ANNOTATION_ONLY / GEOMETRY_MOVED / GEOMETRY_CHANGED / STRUCTURE_ADDED / STRUCTURE_REMOVED / LAYER_CHANGED / CONNECTIVITY_BROKEN / TEXT_LOST

  • 像素门:结构看不见的问题(标签偏移、颜色/线宽)用 capture diff 补,变化区域换算回图纸坐标

  • 无头批量:accoreconsole 跑 lint 与 batch,原件不动,输出目录单独放

版本对应

  • 仓库版本 1.0.0 = 本地插件 @local/autocad-workflow 6.7.0 的打包版本

  • 打包时实测:18 个 MCP 工具、52 个符号(13/21/18)、7 套 demo 图纸、9 种判决、5 条内置规则

目录结构

dsh-autocad-toolkit/
├── autocad-workflow-server.py   # MCP 服务器(stdio JSON-RPC,18 个工具)
├── acad_standards.py            # GB 图层/样式/图框/52 个符号定义
├── acad_domain.py               # 领域模型(块、端口、语义)
├── acad_ops.py                  # 绘图与编辑原语(AutoLISP / ActiveX)
├── acad_attrib.py  acad_layer.py  acad_sentry.py  acad_reactor.py
├── acad_rules.py   acad_lint.py   acad_batch.py   acad_digest.py  acad_vision.py
├── cordis.patch.yml.tmpl        # 模板;install.ps1 渲染成 cordis.patch.yml
├── install.ps1 / verify.ps1 / uninstall.ps1
├── demo/                        # 7 套 demo 图纸(机械/电气/工艺/表格/XDATA)
└── docs/REFERENCE.md            # 原始工程文档(英文,含实测数据)

已知限制

  • 热通道只读:AutoLISP 在进程外 vla-load 会永久卡死解释器,entmod 会带崩 CAD;写操作必须走文件路径。

  • 对象反应器只跟踪 start 时刻存在的实体,重建后要重装;每个 AutoCAD 会话装一次。

  • 规则上限 12 条:第 13 条会挤掉最旧的一条。

  • 权限一致:DSH 与 AutoCAD 必须同权限级,否则 0x80080005。

  • TRUSTEDPATHS 是权衡:把 scratch 目录加进受信任路径 = 允许写该目录的人跑 AutoLISP;可 DSH_ACAD_NO_TRUST=1 关掉。

  • 不保证兼容未来 AutoCAD 版本。

安全与隐私

  • 无遥测:不会向作者或第三方服务器发送数据。

  • 截图、临时图纸、日志只落在本地(仓库的 captures/ 与 %LOCALAPPDATA%\dsh-autocad)。

  • 图纸可能含敏感信息,请自行管理备份与访问。

许可

MIT。使用前请阅读 DISCLAIMER.md。


English quick start

What it is — a DeepSeek Harness plugin that exposes your local AutoCAD 2025 as 18 MCP tools (mcp__autocadworkflow__*): GB layering and sheets, 52 symbols with ports and XDATA, port-to-port orthogonal routing, handle-level inspect/edit, structural sentinel verdicts, real ACAD_TABLE BOMs, headless lint/batch, and DWG-to-PDF plotting.

Read DISCLAIMER.md first. These tools really edit and delete drawing entities, batch writes overwrite files when inplace=true, and autocad_run executes arbitrary AutoLISP.

Requirements: Windows 10/11, a licensed AutoCAD 2025, Python 3.10+ with pywin32, DeepSeek Harness desktop.

git clone https://github.com/zzy-super/dsh-autocad-toolkit.git D:\tools\dsh-autocad-toolkit
powershell -ExecutionPolicy Bypass -File D:\tools\dsh-autocad-toolkit\install.ps1
# restart DeepSeek Harness, then ask: "check AutoCAD status" -> autocad_app

Verify: ./verify.ps1 -Live starts the MCP server once and checks all 18 tools. Remove with ./uninstall.ps1. Engineering reference (tests, gotchas): docs/REFERENCE.md.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables AI agents to drive AutoCAD 2024+ and AutoCAD LT through live COM and AutoLISP engines, with support for headless DXF processing, ISO GD&T, P&ID drafting, and Rhino.Inside Grasshopper battery workflows.
      162
      MIT
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to create, read, validate and revise engineering drawings — mechanical parts, architectural floor plans, P&IDs, dimensions and ISO GD&T tolerance checks — either by driving a live AutoCAD session over COM on Windows or headlessly through ezdxf anywhere. Typed tool packs cover symbol libraries, standards-compliant layers and title blocks, takeoff workbooks, and critique of drawings made by others.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to author, read, critique, and validate production CAD drawings through 247 typed tools spanning mechanical parts, architectural plans, P&IDs, takeoffs, and ISO GD&T / dimension-tolerance checks. It drives live AutoCAD over COM on Windows or runs headlessly anywhere via ezdxf, with pack and discovery modes to keep the advertised tool surface cheap.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to automate AutoCAD drafting, drawing understanding, and quantity takeoffs either through a live COM connection on Windows or headlessly via ezdxf on any platform. It covers P&ID, mechanical, and architectural workflows with ISO/ANSI standards — symbols, dimensions, layers, frames, title blocks, parts lists, schedules, and validation of drawings made by others.
      -