dxf
earthtojake/text-to-cad
Generate and validate 2D DXF drawings from Python ezdxf sources for laser/plasma/waterjet cuts and CAD projections.
What is dxf?
Creates 2D DXF files from Python code using ezdxf, supporting both standalone drafting and CAD-backed projections. Use when you need DXF outputs for cutting, profiles, templates, or flat patterns derived from 3D geometry.
- Generate DXF files from Python gen_dxf() functions returning ezdxf documents
- Project and unfold 3D CAD geometry into 2D DXF cut profiles and drawings
- Validate generated DXF outputs deterministically using ezdxf entity/layer checks
- Support multiple output targets with custom output paths and per-target configuration
- Organize geometry on separate layers for cuts, bends, and reference with intent-carrying layer names
How to install dxf
npx skills add https://github.com/earthtojake/text-to-cad --skill dxf- Python interpreter with ezdxf library installed
- For CAD projections: existing 3D STEP geometry generated via $cad skill
How to use dxf
- 1.Write a Python source file with a gen_dxf() function that returns an ezdxf document
- 2.For CAD-backed DXF, first generate the 3D STEP geometry with $cad, then add gen_dxf() to the same source file
- 3.Run: python scripts/dxf path/to/source.py to generate the .dxf output
- 4.Validate the generated DXF using ezdxf checks (entity counts, closed profiles, dimensions)
- 5.Hand off the file path to $cad-viewer for visual review and live viewer link
Use cases
- Create gasket, panel, and template designs as standalone 2D DXF files
- Generate laser/plasma/waterjet cut layouts from parametric Python geometry
- Export flat patterns and unfolded faces from 3D STEP parts as DXF projections
- Produce 2D drawing profiles and outlines derived from CAD solid topology
- Generate SendCutSend-compatible DXF files for manufacturing services
- CAD/mechanical engineers designing parts for sheet cutting or fabrication
- Product designers creating templates, gaskets, and flat-pack components
- Manufacturing engineers preparing cut layouts for laser, plasma, or waterjet machines
- Developers building parametric design tools with 2D DXF output
dxf FAQ
Prefer deriving DXF from actual 3D STEP/solid topology by projecting and unfolding real planar faces. Only use hand-drawn parametric outlines when no reliable 3D topology exists.
Default to millimeters unless the user specifies otherwise. Set explicitly on the document with doc.units = ezdxf.units.MM.
Keep cut geometry and bend/fold lines on separate layers. Include 'bend' in bend-layer names so downstream tools classify them correctly.
Yes, use positional pairs like: python scripts/dxf path/to/a.py=out/a.dxf path/to/b.py=out/b.dxf
Use ezdxf to check entity counts by type/layer, verify closed flags on cut profiles, check drawing extents, and confirm all user-specified dimensions are present.
Full instructions (SKILL.md)
Source of truth, from earthtojake/text-to-cad.
name: dxf description: Generate, regenerate, and validate 2D DXF drawings from Python ezdxf sources. Use for DXF files, 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 .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 definesgen_step(). Use when the DXF is a drawing or profile of a 3D part; create and validate the STEP geometry with$cadfirst, then add the projection in the same source file.
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.
- 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.
Tool
The launcher lives in the DXF skill directory:
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:
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.
Workflow
- 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
$cadfirst, then add or updategen_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. - Write or edit the Python source with meaningful dimensions as named parameters.
- Run
scripts/dxfon explicit Python source targets only; do not run directory-wide generation.
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.
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.
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.
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.
Related skills
More from earthtojake/text-to-cad and the wider catalog.

gcode
Generate, inspect, and validate FDM G-code from 3D meshes using local slicer CLIs.

implicit-cad
Create browser-native implicit CAD models using GLSL signed-distance fields and shader primitives.

render
Render CAD and robot files in CAD Explorer with review links and snapshots.

sdf
Generate, validate, and hand off SDFormat models and worlds for Gazebo and other simulators.

sendcutsend
Preflight validation for SendCutSend.com DXF and STEP/STP orders against official specs and ordering rules.

srdf
MoveIt2 SRDF generation, validation, and planning-semantics workflow for robot manipulation.