Open source · MIT OR Apache-2.0
The open CAD engine, in pure Rust.
Read DWG, DGN, DXF and CityGML. Write DXF, DGN V8 and CityGML. From Rust, Python, JavaScript and C.
cargo add cadkitpip install pycadkitnpm install cadkit-wasmDownload cadkit-capi-<target> (headers, shared and static library)GitHub Releases
- File
- cadkit-sample-plan.dxf
- Format
- DXF AC1032
- Entities
- 161
- Layers
- 7
- Units
- meter
Rendered at build time by cadkit-wasm 0.5.3. Download the DXF sample plan (31 KB)
Formats
Every reader produces the same format-neutral document. Readers degrade instead of failing: records they cannot model become Unknown entities and warnings on the document.
| Format | Read | Write | Status | Evidence |
|---|---|---|---|---|
| DWG | ReadAC1014 (R14) to AC1032 (2018), including 2007 | No writer | Read-only. R13 (AC1012) is untested; entity coverage is still growing. | |
| DGN V7 | Readincluding tags | No writer | Implemented, including tags. | |
| DGN V8 | Read | Subsetseed-based V8 writer | Local tests pass; external application acceptance is pending. Writing needs a seed file. | |
| DXF | ReadASCII and binary, R12 to 2018 | WriteASCII, R12 to 2018 | Entity coverage is still growing. | |
| CityGML 2.0 | Readnative XML and geometry | Writenative XML and explicit generic geometry | New geometry needs an explicit CRS. Optional local structural TKGM preflight; not institutional acceptance. |
Every interface also writes the document as JSON and SVG. There is no DWG writer yet. Local test evidence and the remaining external acceptance work are recorded in INTERCHANGE_STATUS.md.
The same task in four languages
Open the sample plan, list its layers, export SVG. File I/O and document operations ship for Rust, Python, JavaScript (WebAssembly, browser and Node) and C, with a C++17 wrapper over the C ABI.
- The site's snippet checks run the Python and JavaScript snippets on the sample plan, type-check the Rust one with
cargo checkand compile the C one againstcadkit.h. - The C API returns layer names inside the document JSON; the C example prints the count.
- Rust API reference: docs.rs/cadkit.
fn main() -> Result<(), Box<dyn std::error::Error>> { let doc = cadkit::open("cadkit-sample-plan.dxf")?; for layer in &doc.layers { println!("{}", layer.name); } let options = cadkit::SvgOptions::new().with_width_px(1200.0); std::fs::write("plan.svg", cadkit::to_svg(&doc, &options))?; Ok(())}import cadkit
doc = cadkit.read("cadkit-sample-plan.dxf")for layer in doc.layers: print(layer["name"])with open("plan.svg", "w", encoding="utf-8") as f: f.write(doc.to_svg(width=1200))const { read } = require("cadkit-wasm/node");const fs = require("node:fs");
const doc = read(fs.readFileSync("cadkit-sample-plan.dxf"));for (const layer of doc.layers()) { console.log(layer.name);}fs.writeFileSync("plan.svg", doc.toSvg({ widthPx: 1200 }));doc.free();#include <stdio.h>#include "cadkit.h"
int main(void) { cadkit_document *doc = NULL; if (cadkit_read_file("cadkit-sample-plan.dxf", NULL, &doc) != CADKIT_OK) { fprintf(stderr, "%s\n", cadkit_last_error_message()); return 1; } /* Layer names are in the document JSON (cadkit_document_to_json). */ cadkit_info info; if (cadkit_document_info(doc, &info) == CADKIT_OK) printf("%llu layers\n", (unsigned long long)info.layer_count);
cadkit_svg_options options; cadkit_svg_options_init(&options); options.width_px = 1200; char *svg = NULL; if (cadkit_document_to_svg(doc, &options, &svg) == CADKIT_OK) { FILE *out = fopen("plan.svg", "w"); if (out) { fputs(svg, out); fclose(out); } cadkit_string_free(svg); } cadkit_document_free(doc); return 0;}Modules you can adopt independently
The facade and format crates do not depend on the scene or GPU crates. Pick geometry and rendering separately; the host application supplies its UI, editing tools and domain rules.
Open and export drawings
Format detection, inspection, I/O and access to the neutral document model.
Work with drawing data
Documents, layers, blocks, entities, transforms, units, traversal, limits, JSON and SVG.
Use a format directly
The readers and supported writers, one crate per format.
Compute geometry
Analytic curves, polygon booleans, trim/offset, calibration and supported NURBS operations. Depends on no other cadkit crate.
Prepare scene data without a GPU
Chunked 2D plans, precision budgets, CPU handoff and f64 triangle meshes.
Draw with a GPU
wgpu plan and mesh renderers, cameras, render targets and readback. Opens no window; the host supplies the UI.
Integrate from another interface
The cadkit CLI and the C ABI with a C++17 wrapper. Python (pycadkit) and JavaScript (cadkit-wasm) packages cover file I/O and documented subsets of the document operations.
Clean-room, with a ledger of sources
cadkit is built only from allowed references. Every source of format knowledge is recorded in PROVENANCE.md.
Allowed references
- The public Open Design Specification for DWG
- MIT-licensed projects: ACadSharp, ezdgn and the DGN driver of GDAL
- Public sample files and our own analysis of them
Code or headers from copyleft-licensed CAD projects and from vendor SDKs are never read or ported.
Untrusted input
- No panics on any input
- Every size and count checked against configurable limits before allocation
- Recoverable problems become warnings on the document
- Every reader has a fuzz target that runs in CI
Built for
Drawing viewers and editors
Read a drawing into one document model, render it as SVG or with the wgpu plan renderer, and keep your own UI and editing tools.
Converters and export pipelines
Convert to DXF, seed-based DGN V8, CityGML 2.0, SVG or JSON from a library, the CLI or a script, with bounded stdin/stdout conversion in the CLI.
GIS and CityGML pipelines
Read and write CityGML 2.0 with an explicit CRS, keep native IDs and references, and run an optional local structural TKGM preflight.
Inspection services
Header-only inspection, configurable resource limits on every reader and warnings with stable codes for files you did not create.
Used by
- Cady, an architectural CAD application, uses
cadkit-geom,cadkit-sceneandcadkit-gpu.
cadkit is vendor-neutral. Using it in your project? Say so in GitHub Discussions.
Start with the docs
Install one package, open a drawing, export it. The rest of the API builds on that.