跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
搜索与研究

dxf

Generate, regenerate, and validate 2D DXF drawings from Python ezdxf sources. Use for DXF files, `.dxf.py` generators, gen_dxf() sources, 2D profiles, outlines, templates, gaskets, panels, flat patterns, laser/plasma/waterjet cut layouts, and 2D drawing exports of CAD geometry.

earthtojake · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add earthtojake/text-to-cad --skill dxf

技能说明


name: dxf description: Generate, regenerate, and validate 2D DXF drawings from Python ezdxf sources. Use for DXF files, .dxf.py generators, gen_dxf() sources, 2D profiles, outlines, templates, gaskets, panels, flat patterns, laser/plasma/waterjet cut layouts, and 2D drawing exports of CAD geometry.

DXF generation and validation

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.

Purpose

Create or modify 2D DXF drawings from natural-language requirements or from CAD geometry, generate validated drawing artifacts, and return checked outputs. A DXF drawing's source of truth is a dedicated Python generator file named <name>.dxf.py defining gen_dxf(); the CLI owns output paths.

The default build product is the drawing package — a render artifact the CAD Viewer serves and auto-regenerates:

<model-folder>/__cadgen__/models/<name>.dxf.py/
  drawing.json    # provenance + freshness descriptor
  drawing.dxf     # the built DXF (the exchange artifact)
  preview.glb     # the baked 3D flat pattern (what the viewer renders)

preview.glb is baked from drawing.dxf by a Node child of the build, inside the same generation lock, so a build produces both payloads or neither. It needs node on PATH (or CADGEN_NODE).

The sibling <name>.dxf file is written on demand only (--write, -o, or a SOURCE=OUTPUT pair) for deliverables handed to cutting services or other tools. An exported .dxf is a point-in-time deliverable, totally detached from its generator: rebuilds never delete, rewrite, or staleness-track it (same as an exported STEP file) — re-export when you want it refreshed. Do not commit generated .dxf outputs; the package cache is gitignored and rebuilt on demand.

The three DXF workflows

Copy the full generator template for the applicable workflow from references/generator-templates.md when creating a new drawing.

  1. DXF generated from scratch (standalone drafting — gaskets, panels, templates, cut layouts with no 3D model behind them): a <name>.dxf.py that builds an ezdxf document directly.

  2. DXF derived from a generated STEP part (flat patterns / profiles of a $cad model): a <name>.dxf.py beside the <name>.step.py it projects. Generator entry files use dotted extensions and cannot be imported by module name, so reuse the STEP source's geometry by path-loading it:

    from pathlib import Path
    from cadgen.sources import load_source_module
    
    _step = load_source_module(Path(__file__).with_name("bracket.step.py"))
    
    def gen_dxf():
        return {"document": _step.build_dxf()}
    

    Keep the shared drawing logic (e.g. a build_dxf() helper that unfolds the part via cadgen.flatten) in the .step.py or a plain helper module; the .dxf.py is the drawing entry point. The loaded .step.py and its imports are recorded in the drawing's source closure, so editing the 3D part automatically invalidates the cached drawing.

  3. DXF derived from an imported STEP (a .step/.stp file with no Python source): a <name>.dxf.py that reads the STEP (e.g. build123d.import_step) and projects it with cadgen.flatten. Only Python sources are freshness inputs — like a gen_step() that composes imported STEPs, the drawing does not auto-rebuild when the imported file changes; rerun with --force after replacing it.

gen_dxf() must live in a dedicated .dxf.py file: a source defining both gen_step() and gen_dxf() is rejected. A plain <name>.py defining only gen_dxf() is still accepted as an explicit CLI target (the CLI is naming-agnostic), but only .dxf.py files are catalog entries the CAD Viewer lists and rebuilds.

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.

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 (generation validation enforces this — see Validation).
  • For CAD-backed parts, derive DXF cut contours from the actual STEP/solid topology with cadgen.flatten: select the real planar faces (planar_faces), project and union them (union_projected_faces), and emit clean closed contours (add_shapely_geometry). Use hand-drawn parametric outlines only when there is no reliable 3D topology to project.
  • Apply kerf / tool-radius compensation with cadgen.flatten.offset_geometry / offset_closed_points when the cutting process requires it; do not hand-offset coordinates.
  • 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.

Tool

The skill has two launchers, split on who the source is — the same split the CAD skill uses between scripts/gen and scripts/artifact:

python scripts/gen targets... [flags]        # gen_dxf() Python generators
python scripts/artifact target [flags]       # one drawing, INCLUDING an imported .dxf
python scripts/snapshot --input <drawing> --output <file.png>   # render it

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

阅读完整来源 ↗