Qcad logo

Qcad

Community
znlgis
qcad

Use when editing or batch-converting DXF/DWG drawings with QCAD 3.33 — RAddObjectsOperation scripting, dwginfo/dwg2pdf/dwg2svg console tools, or version conversion through `qcad -no-gui -autostart SaveAs.js -filter`; also when dwg2pdf/dwg2svg are missing because they ship only with QCAD Professional, when a PDF export drops white entities, or when `-no-gui` runs never exit. QCAD: 2D CAD whose native format is DXF, scriptable via ECMAScript.

Overview

Publisherznlgis
Repositoryopengis-skills
Skill nameqcad
Stars
76
Forks
12
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by znlgis on GitHub. Read the source before you install it.

Installation

Install the Qcad AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/znlgis/opengis-skills/tree/main/cad/qcad
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/znlgis/opengis-skills.git /tmp/opengis-skills
mkdir -p .claude/skills
cp -r /tmp/opengis-skills/cad/qcad .claude/skills/qcad
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Qcad in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Qcad on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Qcad is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

项目地址: https://github.com/qcad/qcad

官网: https://qcad.org/

官方文档: https://qcad.org/en/qcad-documentation

API 参考: https://api.qcad.org/

许可证: GPL-3.0(社区版);Pro 版商业许可

最新稳定版: 3.33.1(2026-09-08,GitHub tag v3.33.1.0;截至 2026-10 未发新版,下一版将切换到日历版本号 27.x,见 Changelog 与 https://qcad.org/en/download)

概述

QCAD 由两部分组成:

  • QCAD Community Edition:开源核心,支持 DXF(自带)+ DWG(需要 Teigha/ODA File Converter 或 LibreDWG)
  • QCAD/CAM 与 QCAD Pro:商业插件(数控、PDF、SVG 详细输出等)

核心能力:

  • 2D 绘图:线/弧/圆/多段线/样条/标注/填充/文本
  • 图层、块、视图、布局、打印
  • DXF/DWG/PDF/SVG 输入输出
  • ECMAScript(QtScript / V8)脚本扩展
  • 脚本接口:QCAD 提供 ECMAScript(JavaScript)脚本接口用于二次开发,相关仓库为 qcad/qtjsapi 与 qcad/qcadjsapi
  • 命令行:qcad 本体 + Pro 版附带的控制台工具(dwginfo、dwg2pdf、dwg2svg、dwg2bmp 等,见「命令行批处理」)

安装

bash
# 二进制:<https://qcad.org/en/download>
# Linux 自带:sudo apt install qcad

# 命令行
qcad             # 启动 GUI
qcad -no-gui -autostart script.js   # 无界面运行脚本

将 ODA File Converter(免费)放在 PATH 中以支持 DWG。


项目结构

text
qcad-installation/
├── qcad             # 主程序
├── plugins/         # 二进制插件
├── scripts/         # 脚本扩展(自带 + 用户)
│   ├── Draw/
│   ├── Modify/
│   ├── File/
│   └── Examples/
└── doc/api/         # API 文档(同 api.qcad.org)

用户脚本目录:$HOME/.qcad/scripts(Linux)或对应路径。


ECMAScript 入门:画一条线

javascript
include("scripts/EAction.js");

function MyLine(guiAction) { EAction.call(this, guiAction); }
MyLine.prototype = new EAction();

MyLine.prototype.beginEvent = function() {
    EAction.prototype.beginEvent.call(this);
    var doc = this.getDocument();

    var line = new RLineEntity(doc, new RLineData(
        new RVector(0, 0), new RVector(100, 50)));

    var op = new RAddObjectsOperation();
    op.addObject(line);
    doc.applyOperation(op);

    this.terminate();
};

将文件保存为 ~/.qcad/scripts/MyLine.js 并通过 Misc → Run script,或在控制台调用。


脚本控制台(Tools → Script Shell)

javascript
var doc = getDocument();
print(doc.getEntityIdsByType(RS.EntityLine).length);

// 添加圆
var circle = new RCircleEntity(doc, new RCircleData(new RVector(0,0), 10));
var op = new RAddObjectsOperation();
op.addObject(circle);
doc.applyOperation(op);

命令行批处理

Pro 版控制台工具

QCAD Professional 安装目录自带一批转换与信息提取工具(社区版不含),统一形式为 <tool> [OPTIONS]... <drawing file>,输入既可以是 DWG 也可以是 DXF(同一套读取器),输出文件名由输入名推导:

工具用途
dwginfo / dxfinfo列出图层、块或实体总数
dwg2csv实体导出为 CSV
dwg2bmp / bmp2dwg图纸 → 位图(BMP/PNG…)/ 位图 → 图纸
dwg2svg / svg2dwg图纸 ↔ SVG
dwg2pdf图纸 → PDF
dwg2dwg / pdf2dwg版本转换 / PDF → DXF
dwghatch / dwghatcharea生成填充 / 统计填充面积
dwgexplode炸开块参照
merge / bbox合并图纸 / 求包围盒
dwgmapconvert / dwg2maptiles地理坐标转换 / 生成地图切片
dwgnestCAM 排料(属 QCAD/CAM)

工具名以 dwg2* 起头(表示读 DWG/DXF),没有 dxf2pdf、dxf2svg、dxf2bmp 这类名字。Windows 下是安装目录里的 .bat 批处理,macOS 下是 QCAD-Pro.app/Contents/Resources 内的 shell 脚本,Linux 下是安装目录内的 shell 脚本。

bash
# 各工具的完整开关以官方 Command Line Tools 页与 Usage 输出为准
dwginfo drawing.dxf        # 图层 / 块 / 实体统计
dwg2pdf drawing.dxf        # → drawing.pdf
dwg2svg drawing.dxf        # → drawing.svg
dwg2bmp drawing.dxf        # → 位图

# Changelog 中记录的开关示例
dwg2pdf -color-correction drawing.dxf   # 防止白底白线导出(dwg2svg 同名开关)
dwg2pdf -auto-orientation drawing.dxf   # 按块包围盒自动选择纸张方向

用 qcad 本体做无界面转换

控制台工具不够用时(自定义过滤、批量另存版本),直接驱动 qcad:

bash
qcad -no-gui -autostart scripts/File/SaveAs/SaveAs.js \
     -filter "DXF 2000" -outfile output.dxf input.dxf

-no-gui 无界面、-autostart 启动后执行脚本、-exec 执行后退出、-filter 指定导入过滤器、-outfile 指定输出文件。


自动化批处理(无界面脚本)

把输入文件跟在命令行末尾,-autostart 指定的脚本用 getDocument()(或 EAction 里的 this.getDocument())就能拿到它,不必自己写导入逻辑:

bash
# 逐文件调用自带脚本:读 DWG,按 DXF 2000 过滤器另存
for f in *.dwg; do
    qcad -no-gui -autostart scripts/File/SaveAs/SaveAs.js \
         -filter "DXF 2000" -outfile "out/${f%.dwg}.dxf" "$f"
done

QCAD 自带的转换脚本位于安装目录的 scripts/File/(另存、导出等)与 Pro 版的 scripts/Pro/(如 PDF 导出)下,文件名以安装目录实际内容为准;-outfile 指定输出路径,-filter 指定导入过滤器 / 版本。

需要更细的控制时,脚本内部直接用前文的 RDocument + RAddObjectsOperation / RModifyObjectsOperation 批量改实体,再走另存或控制台工具出图。


实体与文档 API

javascript
var doc = getDocument();

// 遍历所有实体
var ids = doc.queryAllEntities();
for (var i = 0; i < ids.length; ++i) {
    var e = doc.queryEntity(ids[i]);
    if (isLineEntity(e))
        print("LINE", e.getStartPoint(), "→", e.getEndPoint());
}

// 修改图层
var layer = new RLayer(doc, "WALL", false, false,
    new RColor("#ff0000"), doc.getLinetypeId("CONTINUOUS"), RLineweight.Weight030);
var op = new RAddObjectsOperation();
op.addObject(layer);
doc.applyOperation(op);

常用操作

操作API
添加RAddObjectsOperation
修改RModifyObjectsOperation
删除RDeleteObjectsOperation
平移/旋转/缩放RModifyObjectsOperation + RTransform*
选择集getDocumentInterface().getStorage().queryAllSelectedEntities()
块RBlockReferenceEntity + RBlock

打印与布局

  • 视图(Layouts)→ Block-based Page Layout
  • 打印对话框:File → Print;支持多布局批量
  • 通过脚本:RGraphicsSceneQt + RPrinter

典型工作流

工作流一:ECMAScript 脚本自动绘图

  1. 创建 .js 脚本文件,include("scripts/EAction.js") 引入基础类
  2. 继承 EAction,在 beginEvent() 中通过 this.getDocument() 获取文档
  3. 构建 RLineEntity/RCircleEntity 等实体对象
  4. 使用 RAddObjectsOperation 批量添加实体
  5. doc.applyOperation(op) 提交操作
  6. 通过 Misc → Run script 运行,或 qcad -no-gui -autostart script.js 无界面执行

工作流二:命令行批量格式转换

  1. 单个文件转格式:dwg2pdf / dwg2svg / dwg2bmp 直接吃 DWG 或 DXF,输出名由输入名推导
  2. 先摸底再批量:dwginfo 列图层、块与实体数,确认图纸不是空布局
  3. 白色实体导出丢失时给 dwg2pdf / dwg2svg 加 -color-correction
  4. 需要指定 DXF 版本或自定义过滤器时改用 qcad -no-gui -autostart … -filter … -outfile …
  5. Shell 循环遍历目录,把控制台工具或上述 qcad 命令逐文件调用

性能优化

  1. 大文件:编辑期关掉暂不参与的图层(Layers 对话框),减少每次操作的重绘与求交开销
  2. 使用 RDocument + RMemoryStorage 处理无 UI 转换
  3. RAddObjectsOperation.addObject(obj, false) 不立即更新空间索引
  4. 大量实体批量提交后再 applyOperation
  5. 禁用快照(snap)与轨迹(tracking)以加速绘制

常见问题

问题解决
DWG 打不开CE 的 DWG 支持有限:在 Preferences → File I/O 配置 ODA File Converter,或先用其把 DWG 转成 DXF 再处理
字体缺失复制 .shx/.ttf 到 fonts/ 目录或安装到系统
中文显示乱设置图层使用支持 CJK 的字体(如 simhei)
脚本路径错使用绝对路径或 documentInterface.getDocument()
找不到 dwg2pdf / dwg2svg它们是 QCAD Professional 安装自带的控制台工具,社区版没有;Windows 为安装目录下的 .bat,macOS 在 QCAD-Pro.app/Contents/Resources,Linux 为安装目录下的 shell 脚本
导出的 PDF / SVG 里白色实体看不见白底白线,用 dwg2pdf -color-correction / dwg2svg -color-correction
批量改 DXF 版本qcad -no-gui -autostart scripts/File/SaveAs/SaveAs.js -filter "DXF 2000" -outfile out.dxf in.dxf
-no-gui 跑完不退出改用 -exec script.js(执行完即退出),或在脚本里自行结束流程

AI 使用建议

  • 推荐工作流模式:AI 助手应根据场景选择 QCAD 接口——交互式操作使用 GUI 命令,批处理使用 Pro 版控制台工具(dwginfo、dwg2pdf、dwg2svg、dwg2bmp 等),控制台工具覆盖不到的转换用 qcad -no-gui -autostart script.js 无界面运行脚本。ECMAScript 脚本遵循「获取文档 → 构建操作(RAddObjectsOperation 等)→ applyOperation」的模式。
  • 关键注意事项:① 社区版的 DWG 支持有限,需 ODA File Converter 或先转 DXF;② 脚本需 include("scripts/EAction.js") 继承 EAction;③ 批量操作使用 RAddObjectsOperation.addObject(obj, false) 不立即更新空间索引,最后统一 applyOperation;④ 中文字体使用 CJK 支持的 TTF(如 simhei);⑤ 控制台工具只在 Professional 安装中存在,且各平台位置不同。
  • 常用代码模式:简单的几何添加:var line = new RLineEntity(doc, new RLineData(new RVector(0,0), new RVector(100,50))) → var op = new RAddObjectsOperation() → op.addObject(line) → doc.applyOperation(op)。CLI 转换:dwg2pdf drawing.dxf / dwg2svg drawing.dxf(输入可为 DWG 或 DXF,输出名由输入名推导)。
  • 不要臆造:不存在 dxf2pdf、dxf2svg、dxf2bmp 这类命令;dwg2dxf 是 LibreDWG 的工具而非 QCAD 控制台工具列表中的条目;QCAD 脚本 API 名称以 https://api.qcad.org/ 为准,未确认的类名与开关不要写进代码。

相关技能


参考资源

Frequently asked questions

What does the Qcad AI skill do?

Use when editing or batch-converting DXF/DWG drawings with QCAD 3.33 — RAddObjectsOperation scripting, dwginfo/dwg2pdf/dwg2svg console tools, or version conversion through `qcad -no-gui -autostart SaveAs.js -filter`; also when dwg2pdf/dwg2svg are missing because they ship only with QCAD Professional, when a PDF export drops white entities, or when `-no-gui` runs never exit. QCAD: 2D CAD whose native format is DXF, scriptable via ECMAScript.

Why use Qcad on TypingMind?

Because you install it once and use it with any model. Qcad is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Qcad in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/znlgis/opengis-skills/tree/main/cad/qcad. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Qcad?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Qcad?

As many as you like. As long as a model supports skills, you can use Qcad with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Qcad AI skill free?

Yes. It is published on GitHub by znlgis under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇