cad-dxf-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDXF generation and validation
DXF 生成与验证
Provenance: maintained in earthtojake/text-to-cad.
Use the installed local skill files as the runtime source of truth; the
repository link is only for provenance and release review.
来源说明:由 earthtojake/text-to-cad 维护。
请将已安装的本地 skill 文件作为运行时唯一可信来源;仓库链接仅用于来源追溯和发布审查。
Purpose
用途
Create or modify 2D DXF drawings from natural-language requirements or from CAD geometry, generate validated artifacts, and return checked outputs. DXF sources are Python files defining returning an document; the CLI owns output paths.
.dxfgen_dxf()ezdxfTwo source shapes are supported:
- Standalone drafting: a Python source defining only . Use for pure 2D outputs — gaskets, panels, templates, cut layouts — with no 3D model behind them.
gen_dxf() - CAD projection: a added to a CAD generator source that also defines
gen_dxf(). Use when the DXF is a drawing or profile of a 3D part; create and validate the STEP geometry withgen_step()first, then add the projection in the same source file.the cad-generation-skill (load via skill tool)
根据自然语言需求或 CAD 几何数据创建或修改 2D DXF 图纸,生成经过验证的 成品,并返回已检查的输出。DXF 源是定义 并返回 文档的 Python 文件;输出路径由 CLI 管理。
.dxfgen_dxf()ezdxf支持两种源文件形式:
- 独立制图:仅定义 的 Python 源文件。适用于不需要关联 3D 模型的纯 2D 输出,例如垫片、面板、模板和切割布局。
gen_dxf() - CAD 投影:在同时定义 的 CAD 生成器源文件中添加
gen_step()。当 DXF 是某个 3D 零件的图纸或轮廓时使用;应先通过gen_dxf()创建并验证 STEP 几何数据,然后在同一个源文件中添加投影。the cad-generation-skill (load via skill tool)
Use this skill when
何时使用此 skill
Use this skill when the user asks for DXF files, 2D drawings, profiles, outlines, templates, gaskets, panels, flat patterns, or cut layouts for laser, plasma, waterjet, or CNC routing.
Use for the 3D part or assembly a DXF derives from. Use for SendCutSend-specific upload preflight.
the cad-generation-skill (load via skill tool)the cad-sendcutsend-skill (load via skill tool)当用户要求生成 DXF 文件、2D 图纸、轮廓、外形、模板、垫片、面板、展开图,或用于激光、等离子、水刀及 CNC 加工的切割布局时,使用此 skill。
对于 DXF 所派生的 3D 零件或装配体,使用 。对于 SendCutSend 专属的上传预检,使用 。
the cad-generation-skill (load via skill tool)the cad-sendcutsend-skill (load via skill tool)Defaults
默认设置
Use these defaults unless the user specifies otherwise:
- Units: millimeters; set them explicitly on the document ().
doc.units = ezdxf.units.MM - Geometry lives in modelspace at 1:1 scale.
- Cut profiles are closed polylines or closed line/arc loops; open contours only for engraving or reference geometry.
- For CAD-backed parts, prefer deriving DXF cut contours from the actual STEP/solid topology in the same generator script: build the 3D shape, select/project the real planar faces, unfold them into flat coordinates, and emit closed contours from those projected face wires. Use hand-drawn parametric outlines only when there is no reliable 3D topology to project.
- Layers carry intent: keep cut geometry and bend/fold lines on separate layers, and include "bend" in bend-layer names so downstream tools classify them as bends rather than cuts.
- DXF layers are drawing structure, not STEP part/assembly structure.
除非用户另有指定,否则使用以下默认设置:
- 单位:毫米;在文档中明确设置()。
doc.units = ezdxf.units.MM - 几何数据以 1:1 比例存放在 modelspace 中。
- 切割轮廓应为闭合 polyline 或由线和圆弧组成的闭合回路;开放轮廓仅用于雕刻或参考几何数据。
- 对于基于 CAD 的零件,应优先在同一生成器脚本中从真实的 STEP 或实体拓扑派生 DXF 切割轮廓:构建 3D 形状,选择并投影真实的平面面,将其展开为平面坐标,并根据投影后的面边界生成闭合轮廓。仅当没有可靠的 3D 拓扑可供投影时,才使用手工绘制的参数化轮廓。
- 图层用于表达设计意图:将切割几何数据与折弯或折叠线放在不同图层,并在折弯图层名称中包含 "bend",以便下游工具将其识别为折弯线而非切割线。
- DXF 图层表示图纸结构,而不是 STEP 零件或装配体结构。
Tool
工具
The launcher lives in this skill directory:
bash
python scripts/dxf targets... [flags]Use the active project Python interpreter; treat as an interpreter placeholder, and use for the full interface. Target paths resolve from the command's current working directory; run from the workspace that owns the artifacts with cwd-relative target paths. Keep a DXF output and its Python generator in the same directory with the same basename unless the user requests otherwise.
python--helpA DXF target is a Python source defining:
python
def gen_dxf():
...
return documentPlain generated Python targets write sibling outputs. Use / only with one plain generated Python target, or use positional pairs for per-target custom outputs. Do not put output paths in the return value.
.dxf-o--outputSOURCE.py=OUTPUT.dxfgen_dxf()scripts/dxf.dxfezdxfthe cad-viewer-skill (load via skill tool)启动器位于此 skill 目录中:
bash
python scripts/dxf targets... [flags]使用当前项目活跃的 Python 解释器;将 视为解释器占位符,并使用 查看完整接口。目标路径根据命令的当前工作目录解析;请从管理成品的 workspace 运行命令,并使用相对于当前工作目录的目标路径。除非用户另有要求,否则应将 DXF 输出文件及其 Python 生成器放在同一目录,并使用相同的文件基础名。
python--helpDXF 目标是一个 Python 源文件,其形式如下:
python
def gen_dxf():
...
return document普通生成的 Python 目标会写出同目录下的 输出文件。仅当目标为一个普通生成的 Python 文件时使用 /;或者使用 位置参数对,为每个目标指定自定义输出。不要在 的返回值中包含输出路径。
.dxf-o--outputSOURCE.py=OUTPUT.dxfgen_dxf()scripts/dxf.dxfezdxfthe cad-viewer-skill (load via skill tool)Workflow
工作流
- Convert the request into a short brief: outline dimensions, holes and slots, layers, units, output path, and validation targets.
- For CAD projections, generate and validate the STEP geometry with first, then add or update
the cad-generation-skill (load via skill tool)in the same source. When possible, derive the DXF from in-memory STEP/solid topology rather than duplicating geometry formulas, so the DXF remains a direct projection/unfold of the part being exported.gen_dxf() - Write or edit the Python source with meaningful dimensions as named parameters.
- Run on explicit Python source targets only; do not run directory-wide generation.
scripts/dxf
bash
python scripts/dxf path/to/source.py
python scripts/dxf path/to/source.py -o path/to/output.dxf
python scripts/dxf path/to/a.py=out/a.dxf path/to/b.py=out/b.dxf- Validate the generated DXF deterministically, then hand off and report.
- 将请求转换为一份简短需求说明,包括轮廓尺寸、孔和槽、图层、单位、输出路径及验证目标。
- 对于 CAD 投影,先通过 生成并验证 STEP 几何数据,然后在同一个源文件中添加或更新
the cad-generation-skill (load via skill tool)。尽可能从内存中的 STEP 或实体拓扑派生 DXF,而不是重复几何公式,使 DXF 保持为所导出零件的直接投影或展开结果。gen_dxf() - 编写或编辑 Python 源文件,并将有意义的尺寸定义为具名参数。
- 仅对明确指定的 Python 源文件目标运行 ;不要对整个目录执行生成。
scripts/dxf
bash
python scripts/dxf path/to/source.py
python scripts/dxf path/to/source.py -o path/to/output.dxf
python scripts/dxf path/to/a.py=out/a.dxf path/to/b.py=out/b.dxf- 确定性地验证生成的 DXF,然后交付并报告结果。
Validation
验证
Verify the generated file with targeted checks instead of eyeballing: entity counts by type and layer, closed flags on cut profiles, drawing extents, and every dimension the user specified.
ezdxfpython
import ezdxf
doc = ezdxf.readfile("path/to/output.dxf")
msp = doc.modelspace()
profiles = [e for e in msp.query("LWPOLYLINE") if e.closed]
holes = msp.query('CIRCLE[layer=="0"]')Report only checks that actually ran.
应使用针对性的 检查来验证生成的文件,而不是仅凭肉眼判断:按类型和图层统计实体数量,检查切割轮廓的闭合状态、图形范围,以及用户指定的每一项尺寸。
ezdxfpython
import ezdxf
doc = ezdxf.readfile("path/to/output.dxf")
msp = doc.modelspace()
profiles = [e for e in msp.query("LWPOLYLINE") if e.closed]
holes = msp.query('CIRCLE[layer=="0"]')仅报告实际执行过的检查。
Handoff
交付
After creating or modifying artifacts, you must ALWAYS hand the explicit file path(s) to when that skill is installed and include its live viewer link(s) in the final response. If is unavailable or startup fails, report that and rely on checks instead of silently omitting the handoff.
.dxfthe cad-viewer-skill (load via skill tool)the cad-viewer-skill (load via skill tool)ezdxfFinal responses should include generated files, returned viewer links, validation actually run, and assumptions.
创建或修改 成品后,如果已安装 ,必须始终将明确的文件路径交给该 skill,并在最终回复中包含其实时查看器链接。如果 不可用或启动失败,应明确报告,并改为依赖 检查,不得在未说明的情况下省略交付步骤。
.dxfthe cad-viewer-skill (load via skill tool)the cad-viewer-skill (load via skill tool)ezdxf最终回复应包含生成的文件、返回的查看器链接、实际执行的验证以及所作的假设。