dxf
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。请以本地安装的技能文件作为运行时的可信来源;仓库链接仅用于溯源和版本发布审核。
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.$cad
根据自然语言需求或CAD几何创建或修改2D DXF图纸,生成经过验证的工件,并返回检查后的输出结果。DXF源文件是定义了函数的Python文件,该函数返回一个文档;输出路径由CLI管理。
.dxfgen_dxf()ezdxf支持两种源文件类型:
- 独立绘图:仅定义的Python源文件。适用于无3D模型支撑的纯2D输出——如垫片、面板、模板、切割排版。
gen_dxf() - CAD投影:在同时定义了的CAD生成器源文件中添加
gen_step()。当DXF是3D零件的图纸或轮廓时使用;先通过gen_dxf()创建并验证STEP几何,再在同一源文件中添加投影。$cad
Use this skill when
何时使用此技能
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.
$cad$sendcutsend当用户需要DXF文件、2D图纸、轮廓、外形、模板、垫片、面板、展开图,或用于激光、等离子、水射流、CNC铣削的切割排版时,使用此技能。
若DXF源自3D零件或装配体,请使用处理3D部分。若需针对SendCutSend的上传预检,请使用。
$cad$sendcutsendDefaults
默认设置
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.
- 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。
- 切割轮廓为闭合多段线或闭合线/弧环;仅开放轮廓用于雕刻或参考几何。
- 图层承载设计意图:将切割几何与折弯线放在不同图层,且折弯图层名称中包含“bend”,以便下游工具将其归类为折弯而非切割。
- DXF图层用于图纸结构,而非STEP零件/装配体结构。
Tool
工具
The launcher lives in the DXF 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.dxfezdxf$cad-viewer启动器位于DXF技能目录中:
bash
python scripts/dxf targets... [flags]使用当前项目的Python解释器;将视为解释器占位符,使用查看完整接口。目标路径从命令的当前工作目录解析;请在拥有工件的工作区中运行命令,并使用相对当前工作目录的目标路径。除非用户另有要求,否则请将DXF输出文件与其Python生成器放在同一目录中,并使用相同的基础文件名。
python--helpDXF目标是定义了以下内容的Python源文件:
python
def gen_dxf():
...
return document普通生成的Python目标文件会生成同级的输出文件。仅当处理单个普通生成的Python目标文件时使用/参数,或使用位置参数对为每个目标自定义输出。请勿在的返回值中指定输出路径。
.dxf-o--outputSOURCE.py=OUTPUT.dxfgen_dxf()scripts/dxf.dxfezdxf$cad-viewerWorkflow
工作流程
- 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
$cadin the same source.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几何,再在同一源文件中添加或更新
$cad。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.
.dxf$cad-viewer$cad-viewerezdxfFinal responses should include generated files, returned viewer links, validation actually run, and assumptions.
创建或修改工件后,若已安装,必须始终将明确的文件路径交给,并在最终响应中包含其实时查看链接。若不可用或启动失败,请告知用户,并依赖检查结果,切勿省略交付步骤。
.dxf$cad-viewer$cad-viewer$cad-viewerezdxf最终响应应包含生成的文件、返回的查看链接、实际执行的验证项以及做出的假设。