ββββββ ββββββββ ββββββ ββββββββ ββ ββ ββ βββββββ ββββββββ βββββββ ββββββββββββββββββ ββββββββββββββ ββββ βββββββββββββββββ ββββ βββ ββββ ββββ βββββββ ββββ βββ ββββ ββββββββββββββ ββββ ββββ βββ ββββ ββββ ββββββββ ββββ ββββ βββββββ βββββββ ββββ ββββββββ ββββββββββββββββββ ββββ ββββββββββββ βββββββ βββββββββ ββββββ βββββββ ββββββββ βββ βββββββββββ ββββββ βββββββ
cadforge is an Architecture as Code CLI tool and Rust library for declarative 2D CAD modeling. Write geometry as code in .cf TOML format, compile to DXF, and generate PNG previews for AI agents.
- π Declarative Geometry β Define architectural elements (lines, rects, circles, arcs, polylines, text, dimensions) in TOML
.cffiles. Deterministic, reproducible, version-controlled. - π Layer System β Organize geometry by layer with custom names, colors, and line weights. Compile single layers or full projects.
- π DXF Export β Compile
.cfβ DXF (AutoCAD-compatible). Full layer support, LWPOLYLINE for polylines, HATCH for solid fills, MTEXT for annotations. - πΌοΈ PNG Preview β Generate raster previews with metadata JSON for AI agent integration. Renders fills, hatches, strokes, and text with boundary resolution. Configurable resolution and layer filtering.
- β
Validation Engine β
cadforge checkvalidates geometry without generating output. Shows project metadata, layer colors, and entity counts.
- Project Scaffolding β
cadforge newcreates a complete multi-layer project (muros, puertas, mobiliario, cotas) with meaningful architectural examples. - Multi-Layer Compilation β Compile all layers or target specific layers with
--layer. Custom output path with--output. - Auto-Rebuild β
cadforge watchmonitors.cfand.tomlfiles and auto-rebuilds on changes with 300ms debounce. - Code Formatting β
cadforge fmtnormalizes.cffiles.--checkmode for CI validation. - Boundary Resolution β Automatic detection of closed boundaries for hatch generation. Shared boundary resolution across overlapping entities.
- Polyline Support β Full LWPOLYLINE support with bulge factors for arcs. Proper vertex handling and closure detection.
- Compiler Pipeline β Parse β Resolve β Compile β Emit. Modular design for easy extension.
- DXF Writer β Direct DXF entity writing with proper AutoCAD compatibility. Layer/color/lineweight mapping.
- Preview Renderer β Tiny-skia based raster rendering with anti-aliasing. PNG + JSON metadata output.
- Error Reporting β Structured errors with file, line, and context. Fast-fail on validation errors.
| Command | Description |
|---|---|
cadforge new <name> |
Create a new project with multi-layer scaffold |
cadforge init |
Initialize CADforge in current directory |
cadforge build |
Compile project to DXF |
cadforge build --check |
Validate project and constraints without generating DXF |
cadforge build --output <path> |
Compile to custom output path |
cadforge build --layer <name> |
Compile specific layer only |
cadforge check |
Validate with project metadata and layer colors |
cadforge layers |
List layers with entity counts and colors |
cadforge preview |
Generate PNG preview + metadata JSON |
cadforge preview --width 1024 --height 768 |
Custom resolution preview |
cadforge preview --layer <name> |
Preview specific layer only |
cadforge fmt |
Format .cf files (normalize whitespace) |
cadforge fmt --check |
Check formatting without modifying (CI) |
cadforge watch |
Auto-rebuild on file changes |
cadforge import <file.dxf> |
Import DXF into .cf layers + project.toml |
cadforge import <file.dxf> --layer <name> |
Import only one DXF layer |
cadforge view |
Open the project in the configured viewer |
cadforge view --layer <name> |
Open only one layer in the viewer |
cadforge config set <key> <value> |
Set global defaults (author, units) |
cadforge config show |
Show global defaults |
- HUD flotante en pantalla con proyecto, vista, distancia, capas, selecciΓ³n y ayuda de atajos
T/F/V/Rβ top / front / right / isometric preset viewsQ/E/W/Sβ orbit camera- Mouse left-drag β orbit
- Mouse right-drag / arrows β pan
- Mouse wheel /
+/-β zoom 1..9β toggle layer visibility- Click entity edge β select primitive id
- Selected entity is highlighted in amber in the viewport HUD context
Cβ copy selected id to clipboard
[layer]
name = "muros"
color = "#FFFFFF"
[[line]]
id = "ln-001"
from = [0.0, 0.0]
to = [8.5, 0.0]
weight = 0.50
[[rect]]
id = "rc-001"
origin = [1.0, 1.0]
width = 3.5
height = 4.0
[[circle]]
id = "ci-001"
center = [4.0, 3.0]
radius = 0.5
[[arc]]
id = "ac-001"
center = [2.0, 2.0]
radius = 0.9
from_angle = 0.0
to_angle = 90.0
[[polyline]]
id = "pl-001"
vertices = [[0, 0], [5, 0], [5, 3], [0, 3]]
closed = true
[[text]]
id = "tx-001"
position = [4.0, 3.0]
content = "SALA"
size = 0.2
[[dim]]
id = "dm-001"
from = [0, 0]
to = [5, 0]
offset = 0.5line, polyline, rect, circle, arc, text, point, dim, hatch, solid
.cf file (TOML)
β
βΌ
βββββββββββ ββββββββββββ βββββββββββ βββββββββββ
β Parser βββββΆβ Resolver βββββΆβCompiler βββββΆβ DXF Emitβ
βββββββββββ ββββββββββββ βββββββββββ βββββββββββ
β
βΌ
ββββββββββββ βββββββββββββββ
β Boundary βββββΆβ Preview PNG β
β Resolver β β + JSON meta β
ββββββββββββ βββββββββββββββ
- Parser β TOML parsing with custom array-of-tables detection, primitive validation
- Resolver β Layer dependency resolution, coordinate validation, boundary detection
- Compiler β Entity compilation to DXF format, hatch generation, polyline closure
- DXF Writer β Direct DXF entity emission with proper layer/color/lineweight mapping
- Preview Renderer β Tiny-skia raster rendering with hatch/fill support
compiler/β Project compilation pipeline, layer targeting, validation, build statsdxf_writer/β DXF entity writing, LWPOLYLINE, HATCH, MTEXT generationpreview/β PNG rendering with configurable resolution, layer filtering, metadata JSONparser/β TOML parsing, primitive extraction, array-of-tables handlingmodel/β Data structures: Layer, Primitive, Projectscaffold/β Multi-layer project creation with architectural examplesfmt/β .cf file formatting and normalizationwatch/β File system watcher with auto-rebuild and debouncecolor/β Color parsing and DXF color mapping
| Data | Location | Format |
|---|---|---|
| Project files | ./ |
TOML (.cf + project.toml) |
| Build output | output/ |
DXF |
| Preview output | output/preview.png |
PNG |
| Preview metadata | output/preview.json |
JSON |
| Build cache | target/ |
Cargo build |
Create a new project:
cadforge new mi-proyecto
cd mi-proyectoEdit .cf files (TOML format with your geometry)
Format and validate:
cadforge fmt # normalize .cf files
cadforge check # validate without generating DXFCompile to DXF:
cadforge build # default output.dxf
cadforge build --output plano.dxf # custom output path
cadforge build --layer muros # compile single layerPreview:
cadforge preview # default 2048x1536
cadforge preview --width 1024 --height 768 # custom resolution
cadforge preview --layer muros # single layer previewAuto-rebuild on changes:
cadforge watch # monitors .cf and .toml files| Rust 2021 | clap | toml | toml_edit | tiny-skia | dxf | notify | anyhow | serde |
MIT β see LICENSE for details.