cad-dxf-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DXF 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
.dxf
artifacts, and return checked outputs. DXF sources are Python files defining
gen_dxf()
returning an
ezdxf
document; the CLI owns output paths.
Two source shapes are supported:
  • Standalone drafting: a Python source defining only
    gen_dxf()
    . Use for pure 2D outputs — gaskets, panels, templates, cut layouts — with no 3D model behind them.
  • CAD projection: a
    gen_dxf()
    added to a CAD generator source that also defines
    gen_step()
    . Use when the DXF is a drawing or profile of a 3D part; create and validate the STEP geometry with
    the cad-generation-skill (load via skill tool)
    first, then add the projection in the same source file.
根据自然语言需求或 CAD 几何数据创建或修改 2D DXF 图纸,生成经过验证的
.dxf
成品,并返回已检查的输出。DXF 源是定义
gen_dxf()
并返回
ezdxf
文档的 Python 文件;输出路径由 CLI 管理。
支持两种源文件形式:
  • 独立制图:仅定义
    gen_dxf()
    的 Python 源文件。适用于不需要关联 3D 模型的纯 2D 输出,例如垫片、面板、模板和切割布局。
  • CAD 投影:在同时定义
    gen_step()
    的 CAD 生成器源文件中添加
    gen_dxf()
    。当 DXF 是某个 3D 零件的图纸或轮廓时使用;应先通过
    the cad-generation-skill (load via skill tool)
    创建并验证 STEP 几何数据,然后在同一个源文件中添加投影。

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
the cad-generation-skill (load via skill tool)
for the 3D part or assembly a DXF derives from. Use
the cad-sendcutsend-skill (load via skill tool)
for SendCutSend-specific upload preflight.
当用户要求生成 DXF 文件、2D 图纸、轮廓、外形、模板、垫片、面板、展开图,或用于激光、等离子、水刀及 CNC 加工的切割布局时,使用此 skill。
对于 DXF 所派生的 3D 零件或装配体,使用
the cad-generation-skill (load via skill tool)
。对于 SendCutSend 专属的上传预检,使用
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
python
as an interpreter placeholder, and use
--help
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.
A DXF target is a Python source defining:
python
def gen_dxf():
    ...
    return document
Plain generated Python targets write sibling
.dxf
outputs. Use
-o
/
--output
only with one plain generated Python target, or use
SOURCE.py=OUTPUT.dxf
positional pairs for per-target custom outputs. Do not put output paths in the
gen_dxf()
return value.
scripts/dxf
is a generator; it does not inspect existing
.dxf
files. For existing DXF inspection, use
ezdxf
for entity/layer checks and
the cad-viewer-skill (load via skill tool)
for visual review.
启动器位于此 skill 目录中:
bash
python scripts/dxf targets... [flags]
使用当前项目活跃的 Python 解释器;将
python
视为解释器占位符,并使用
--help
查看完整接口。目标路径根据命令的当前工作目录解析;请从管理成品的 workspace 运行命令,并使用相对于当前工作目录的目标路径。除非用户另有要求,否则应将 DXF 输出文件及其 Python 生成器放在同一目录,并使用相同的文件基础名。
DXF 目标是一个 Python 源文件,其形式如下:
python
def gen_dxf():
    ...
    return document
普通生成的 Python 目标会写出同目录下的
.dxf
输出文件。仅当目标为一个普通生成的 Python 文件时使用
-o
/
--output
;或者使用
SOURCE.py=OUTPUT.dxf
位置参数对,为每个目标指定自定义输出。不要在
gen_dxf()
的返回值中包含输出路径。
scripts/dxf
是生成器,不会检查现有的
.dxf
文件。对于现有 DXF 的检查,请使用
ezdxf
执行实体和图层检查,并使用
the cad-viewer-skill (load via skill tool)
进行可视化审查。

Workflow

工作流

  1. Convert the request into a short brief: outline dimensions, holes and slots, layers, units, output path, and validation targets.
  2. For CAD projections, generate and validate the STEP geometry with
    the cad-generation-skill (load via skill tool)
    first, then add or update
    gen_dxf()
    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.
  3. Write or edit the Python source with meaningful dimensions as named parameters.
  4. Run
    scripts/dxf
    on explicit Python source targets only; do not run directory-wide generation.
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
  1. Validate the generated DXF deterministically, then hand off and report.
  1. 将请求转换为一份简短需求说明,包括轮廓尺寸、孔和槽、图层、单位、输出路径及验证目标。
  2. 对于 CAD 投影,先通过
    the cad-generation-skill (load via skill tool)
    生成并验证 STEP 几何数据,然后在同一个源文件中添加或更新
    gen_dxf()
    。尽可能从内存中的 STEP 或实体拓扑派生 DXF,而不是重复几何公式,使 DXF 保持为所导出零件的直接投影或展开结果。
  3. 编写或编辑 Python 源文件,并将有意义的尺寸定义为具名参数。
  4. 仅对明确指定的 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
  1. 确定性地验证生成的 DXF,然后交付并报告结果。

Validation

验证

Verify the generated file with targeted
ezdxf
checks instead of eyeballing: entity counts by type and layer, closed flags on cut profiles, drawing extents, and every dimension the user specified.
python
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.
应使用针对性的
ezdxf
检查来验证生成的文件,而不是仅凭肉眼判断:按类型和图层统计实体数量,检查切割轮廓的闭合状态、图形范围,以及用户指定的每一项尺寸。
python
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
.dxf
artifacts, you must ALWAYS hand the explicit file path(s) to
the cad-viewer-skill (load via skill tool)
when that skill is installed and include its live viewer link(s) in the final response. If
the cad-viewer-skill (load via skill tool)
is unavailable or startup fails, report that and rely on
ezdxf
checks instead of silently omitting the handoff.
Final responses should include generated files, returned viewer links, validation actually run, and assumptions.
创建或修改
.dxf
成品后,如果已安装
the cad-viewer-skill (load via skill tool)
,必须始终将明确的文件路径交给该 skill,并在最终回复中包含其实时查看器链接。如果
the cad-viewer-skill (load via skill tool)
不可用或启动失败,应明确报告,并改为依赖
ezdxf
检查,不得在未说明的情况下省略交付步骤。
最终回复应包含生成的文件、返回的查看器链接、实际执行的验证以及所作的假设。