Logo Dxf

Dxf

Cộng đồngPhổ biến
earthtojake
dxf

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

Tổng quan

Nhà phát hànhearthtojake
Kho mãtext-to-cad
Tên kỹ năngdxf
Sao
16K
Bản fork
1.7K
Tệp đi kèm
3
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 3 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được earthtojake công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Dxf trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/earthtojake/text-to-cad/tree/main/skills/dxf
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/earthtojake/text-to-cad.git /tmp/text-to-cad
mkdir -p .claude/skills
cp -r /tmp/text-to-cad/skills/dxf .claude/skills/dxf
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Dxf trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Dxf ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Dxf với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

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.

Setup

This skill's commands are thin entrypoints over the cadgen distribution, which carries the Python build runtime and the JavaScript it executes. Install it once:

bash
python -m pip install -r requirements.txt

Drawings are build123d geometry, so a drawing build loads the CAD kernel like a STEP build does (~2.5s cold; the warm daemon absorbs it on re-runs). Only cadgen dxf snapshot additionally needs Node 20 or newer on PATH — it meshes the flat pattern on demand through a bundled Node one-shot; a missing node is reported at render time.

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 Python file named <name>.py defining one parameterless @dxf model function.

A drawing is a model. It has the same wrapper, record, freshness gate and build job a @step part has; its one output is the .dxf file; it has no geometry tree (nothing links to a drawing). Every run writes the sibling <name>.dxf (or the out= the decorator names); an unchanged source is a no-op; a drawing that calls a part model — bracket() inside its body — is stale whenever that part's GEOMETRY changes and current when it does not; cadgen store why <drawing>.py explains the verdict; --force rebuilds it anyway. The CAD Viewer and dxf snapshot read the .dxf file itself, so the file you hand a cutting service and the file the viewer renders are one and the same.

The contract

A @dxf function takes no parameters and returns build123d 2D geometry. The engine writes the DXF. You never construct a document, name a file, or place an entity — the same division of labor @step has.

python
from cadgen import build123d as bd
from cadgen import dxf


HOLE_D = 4.5


@dxf
def gasket():
    with bd.BuildSketch() as cut:
        bd.Rectangle(60, 40)
        bd.Circle(HOLE_D / 2, mode=bd.Mode.SUBTRACT)
    return cut.sketch          # bare shape -> the CUT layer


if __name__ == "__main__":
    gasket()
  • Bare shape → one CUT layer. That is the whole contract for most drawings.
  • {layer: shape} → named layers, when the drawing genuinely has more than one CAM operation (CUT / ENGRAVE / SCORE). A Compound whose children are all labelled means the same thing.
  • No parameters. Dimensions are module constants (HOLE_D = 4.5) or constants imported from the part the drawing derives from; a different drawing is a different file.
  • Text is bd.Text(...) engraved OUTLINES on a marking layer, never a DXF TEXT entity: cut and marking toolchains consume geometry, and font rendering inside CAM is unreliable.
  • Geometry must lie in the XY plane. A face taken from a solid sits at that solid's height; relocate it (flatten.flatten_face(face), or bd.Location((0, 0, -z)) * face). The engine REFUSES off-plane geometry rather than silently writing its XY shadow.
  • Output bytes are a function of the geometry. Layers are sorted by name and entities by geometric content, so an unchanged drawing rebuilds to an identical file, cold or warm, on any machine.

The three DXF workflows

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

  1. Drafted from scratch (gaskets, panels, templates, cut layouts with no 3D model behind them): a <name>.py that builds sketches and returns them.

  2. Flat pattern of a generated STEP part: a drawing script beside the model it derives from, with its OWN stem (one model per file — bracket_drawing.py beside bracket.py). Import the model and call it, exactly as an assembly composes a child: importing never builds, and inside the drawing's build the call returns the part's geometry (building the part first if it is stale).

    python
    from cadgen import dxf, flatten
    from bracket import bracket        # a child: tracked by its RESULT
    
    KERF = 0.15
    
    
    @dxf
    def bracket_drawing():
        return flatten.flat_pattern(bracket(), coordinate=3.0, kerf=KERF)
    
    
    if __name__ == "__main__":
        bracket_drawing()

    The drawing's record pins the part's tree, so a part edit that changes its geometry makes the drawing stale, and one that does not (a comment, a refactor, a colour) leaves it current. Constants imported from the part (from bracket import THICKNESS) are tracked by value the same way.

  3. Flat pattern of an imported STEP (a .step/.stp with no Python source): read it with cadgen.read_step, not build123d.import_step. It records the file's content hash as a build INPUT, so replacing the vendor STEP makes the drawing stale on its own, with no --force; read it through build123d and the drawing stays "current" against a file that changed underneath it.

    python
    from pathlib import Path
    
    from cadgen import dxf, flatten, read_step
    
    _HERE = Path(__file__).resolve().parent
    
    KERF = 0.15
    
    
    @dxf
    def panel_flat():
        panel = read_step(_HERE / "imported" / "vendor_panel.step")   # recorded input
        return flatten.flat_pattern(panel, coordinate=3.0, kerf=KERF)
    
    
    if __name__ == "__main__":
        panel_flat()

    Never read a STEP this project generates. Reading the .step a @step model writes is not a loop, it is a drawing whose input changes on every run of the model: the freshness gate can never say "current", every build is a full rebuild, and the flat pattern depends on what the last run left on disk. Keep source STEPs in an imported/ directory beside the drawing, committed like any other input — input path and output path being different files is the whole rule. For a STEP this project DOES generate, use workflow 2 instead: import the model script and call it, which is tracked by result and never touches an artifact.

One model per file is the recommendation, and a drawing gets its own script: a file MAY declare several models — two @dxf drawings, or a @dxf beside a @step — and each is its own record, output and job (a sole model writes <file>.dxf; models sharing a file write <function>.dxf), but they share the file's closure, so editing one rebuilds them all. A drawing composes models, never the reverse: calling a @dxf function from a @step body is just its 2D geometry and links nothing. The viewer catalog is artifacts-only: scripts never list; the .dxf the run writes is the entry the viewer renders.

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. The engine sets them; a drawing never declares units.
  • Geometry lives at 1:1 scale in the XY plane.
  • Cut profiles close. Open contours belong on bend/engrave/reference layers — generation validation enforces this (see Validation).
  • For CAD-backed parts, derive contours from the real topology with cadgen.flatten rather than redrawing them: planar_faces selects, flatten_face lays a face into XY exactly, union_faces fuses, and flat_pattern does all of it in one call. Hand-drawn parametric outlines only when there is no reliable 3D topology.
  • Kerf / tool-radius compensation is flatten.offset_profile(shape, amount) or flat_pattern(..., kerf=...); never hand-offset coordinates.
  • Curves stay curves. The union and the offset are exact OCC operations, so a filleted corner exports as an ARC and a hole as a CIRCLE, kerf included. A profile that comes out as hundreds of short LINEs means something fell back to the sampled path — investigate rather than accept it.
  • 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

bash
python <drawing>.py [flags]                    # its __main__ calls the @dxf model, which writes the .dxf
cadgen dxf snapshot <drawing.dxf> <file.png>   # render it
cadgen store why <drawing>.py                  # why the drawing is stale or current

Running the script (its __main__ call) is the only door. There is no cadgen dxf build: a .dxf has no derived state a command must materialize — the file IS the product, the CAD Viewer parses it directly, and dxf snapshot meshes it on demand. The drawing's gate makes a rebuild cheap: an unchanged source whose .dxf still verifies and whose part children are unchanged is a no-op, and --force rebuilds anyway. The bytes are a function of the drawing's GEOMETRY, so a cold run and a warm daemon worker write the same file. Builds never wait on or cancel one another; a drawing that calls parts builds them in parallel like any parent.

An imported .dxf needs nothing at all — hand it straight to snapshot or the Viewer.

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 drawing script in the same directory as the geometry it derives from, named <name>.py.

Flags (a model script runs itself; there is no generation CLI):

  • --force — regenerate even when the recorded output is current.
  • --verbose, --json.

A run answers on stdout exactly as a STEP model's does — built DXF/plate_drawing.dxf or current DXF/plate_drawing.dxf — with progress on stderr; --json makes the result one JSON line (outcome, document, and tree, which is null for a drawing) and the progress one JSON line per transition.

One script, one drawing: run each script you want built. Do not put output paths in the @dxf function's return value; out= on the decorator is the only place a drawing names its destination (relative to the script).

cadgen dxf snapshot renders a drawing's 3D flat pattern to a PNG still:

bash
cadgen dxf snapshot path/to/imported.dxf review.png
cadgen dxf snapshot path/to/drawing.dxf review.png --camera top

It takes the .dxf document only — a model script is refused by name (run python <drawing>.py, then snapshot the drawing it wrote). The command meshes the flat pattern on demand through the bundled Node one-shot and renders it through the shared snapshot CLI (cadgen.snapshot_cli) and the same headless browser runtime every rendering skill uses. A normal snapshot uses deterministic light CAD lighting and hides grid and axis guides.

OUT — the second positional — is written exactly as given, with a relative path resolved against the current working directory. The target is deleted before the render starts and the finished image is written atomically, so: reuse one name while iterating (every read is provably the render you just ran), name the iterations when you genuinely need to compare two. Invalid request combinations fail before touching OUT; after a request is accepted, OUT is cleared first so a later failure leaves a missing file instead of a stale image. A directory (tmp/ as OUT) is the don't-care case and gets a generated timestamped name inside it, printed on the saved snapshot: line.

Grammar: cadgen dxf snapshot TARGET [OUT] [flags]. Flags: --mode view|list, --camera, --render, --display, --size-profile, --width/--height, --job, --view-labels, --debug, --json. --render opts into the photographic scene and accepts light, dark, compact Render JSON, or a file path. Set the photographic camera inside Render JSON. Top-level --camera and --display control normal drawing snapshots and cannot be combined with Render. A drawing has no selectors, kinematics, section mode, exploded assembly structure, or CAD-edge topology, and those combinations are absent or rejected clearly.

No CLI inspects an existing .dxf. For entity/layer checks read it with ezdxf directly (it arrives with build123d), and validate_dxf_file for the drawing checks; review geometry visually with $cad-viewer.

Workflow

  1. Convert the request into a short brief: outline dimensions, holes and slots, layers, units, output path, and validation targets.
  2. Pick the workflow: drafted from scratch, flat pattern of a generated model (create and validate the 3D geometry with $cad first), or flat pattern of an imported STEP.
  3. Write or edit the <name>.py source with meaningful dimensions as named constants, reusing the model's geometry helpers instead of duplicating formulas.
  4. Run each drawing script directly (python <drawing>.py); do not sweep directories.
bash
python path/to/source.py
python path/to/source.py --force
  1. Validate the generated DXF deterministically, then hand off and report.

Viewer integration

The CAD Viewer catalogs .dxf files only (artifacts, never scripts) and is a static visualization tool: it renders the .dxf that exists on disk (parsing and meshing it itself — 2D line work for dimensioned drawings, a fold-able 3D flat pattern for cut layouts) and never runs a script. A drawing with no .dxf yet simply does not appear until its script has been run; regenerating after edits is likewise the script's job. There is no in-viewer export. An imported .dxf renders directly with no artifact management.

Validation

Validation happens IN generation, not after: every @dxf build runs the drawing checks on the document the engine just serialized, before anything is written, and a build with error findings fails. The checks: cut-layer profiles must close (polylines, circles, or chained line/arc loops), zero-length/degenerate entities are rejected, exact duplicate geometry (double-cut risk) is rejected, explicitly unitless documents are rejected, and an empty modelspace is rejected. Open geometry is allowed only on bend/engrave/reference-intent layers (matched by name).

The same checks run post-hoc on any existing .dxf file — including one that never came from a generator — through cadgen.drawing_checks:

python
from cadgen.drawing_checks import validate_dxf_file

for finding in validate_dxf_file("path/to/file.dxf"):
    print(finding.render())

Beyond the built-in checks, verify requested dimensions with targeted ezdxf reads (entity counts by layer, drawing extents, every dimension the user specified) against the generated sibling .dxf (or the out= path when one is declared), and review geometry visually in the CAD Viewer:

python
import ezdxf

doc = ezdxf.readfile("path/to/source.dxf")
msp = doc.modelspace()
cut = msp.query('*[layer=="CUT"]')
holes = msp.query('CIRCLE[layer=="CUT"]')

Report only checks that actually ran.

Handoff

After creating or modifying DXF drawings, you must ALWAYS hand the explicit .dxf 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.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Dxf làm được gì?

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

Vì sao nên dùng Dxf trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Dxf là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Dxf trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/earthtojake/text-to-cad/tree/main/skills/dxf. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Dxf?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Dxf với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Dxf với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Dxf có miễn phí không?

Có. Kỹ năng này được earthtojake phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇