dxf

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。请以本地安装的技能文件作为运行时的可信来源;仓库链接仅用于溯源和版本发布审核。

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
    $cad
    first, then add the projection in the same source file.
根据自然语言需求或CAD几何创建或修改2D DXF图纸,生成经过验证的
.dxf
工件,并返回检查后的输出结果。DXF源文件是定义了
gen_dxf()
函数的Python文件,该函数返回一个
ezdxf
文档;输出路径由CLI管理。
支持两种源文件类型:
  • 独立绘图:仅定义
    gen_dxf()
    的Python源文件。适用于无3D模型支撑的纯2D输出——如垫片、面板、模板、切割排版。
  • CAD投影:在同时定义了
    gen_step()
    的CAD生成器源文件中添加
    gen_dxf()
    。当DXF是3D零件的图纸或轮廓时使用;先通过
    $cad
    创建并验证STEP几何,再在同一源文件中添加投影。

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
$cad
for the 3D part or assembly a DXF derives from. Use
$sendcutsend
for SendCutSend-specific upload preflight.
当用户需要DXF文件、2D图纸、轮廓、外形、模板、垫片、面板、展开图,或用于激光、等离子、水射流、CNC铣削的切割排版时,使用此技能。
若DXF源自3D零件或装配体,请使用
$cad
处理3D部分。若需针对SendCutSend的上传预检,请使用
$sendcutsend

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.
  • 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
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
$cad-viewer
for visual review.
启动器位于DXF技能目录中:
bash
python scripts/dxf targets... [flags]
使用当前项目的Python解释器;将
python
视为解释器占位符,使用
--help
查看完整接口。目标路径从命令的当前工作目录解析;请在拥有工件的工作区中运行命令,并使用相对当前工作目录的目标路径。除非用户另有要求,否则请将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
进行实体/图层检查,使用
$cad-viewer
进行可视化审查。

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
    $cad
    first, then add or update
    gen_dxf()
    in the same source.
  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投影,先通过
    $cad
    生成并验证STEP几何,再在同一源文件中添加或更新
    gen_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
$cad-viewer
when that skill is installed and include its live viewer link(s) in the final response. If
$cad-viewer
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
工件后,若
$cad-viewer
已安装,必须始终将明确的文件路径交给
$cad-viewer
,并在最终响应中包含其实时查看链接。若
$cad-viewer
不可用或启动失败,请告知用户,并依赖
ezdxf
检查结果,切勿省略交付步骤。
最终响应应包含生成的文件、返回的查看链接、实际执行的验证项以及做出的假设。