acadrust
See third-party notices for DWG code provenance and attribution.
A pure Rust crate for reading, writing, and inspecting CAD files.
acadrust handles ASCII and binary DXF plus native binary DWG without requiring an installed CAD application. File support spans DXF and DWG R12 through R2018+.
Quick Start
[]
= "0.6.7"
use ;
DxfReader detects ASCII and binary input automatically. To produce binary
DXF, use DxfWriter::new_binary(&doc).
Cargo features
| Feature | Default | Adds |
|---|---|---|
parallel |
Yes | Rayon parallelism for native DWG reading and writing |
serde |
No | Serialize and Deserialize implementations for document types |
import |
No | STL, COLLADA, OBJ, glTF/GLB, and FBX importers |
Enable optional features as needed:
[]
= { = "0.6.7", = ["serde", "import"] }
To run DWG work sequentially on the calling thread and omit acadrust's Rayon dependency, disable default features:
[]
= { = "0.6.7", = false }
Cargo features are additive: another dependency enabling acadrust/parallel
can enable it for your application too. Existing applications using
default-features = false must add features = ["parallel"] to retain native
parallelism. WebAssembly remains sequential regardless of this feature.
Limit DWG concurrency
Native DWG reads and writes use the current Rayon pool, or Rayon's shared global pool when called outside a pool. To bound concurrency, create an application-owned pool once and reuse it for all DWG jobs:
[]
= "0.6.7"
= "1"
use DwgReader;
use *;
The batch and acadrust's internal parallel work share these four workers;
reuse the same pool for later batches and wrap writes in pool.install too.
Separate pools or DWG calls outside this pool are not covered by its limit.
A one-thread pool still executes work on a Rayon worker; disabling parallel
keeps acadrust's work on its calling thread.
Features
- DXF I/O — ASCII and binary formats, R12 through R2018+
- DWG I/O — Native binary formats, R12 through R2018+
- Broad entity coverage — 48 top-level
EntityTypevariants covering 2D geometry, annotations, dimensions, meshes, underlays, viewports, 3D solids, regions, bodies, and native surfaces - ACIS modeling data — SAT/SAB parsing and writing, B-rep topology, solid history, and primitive builders
- Tables and objects — Layers, linetypes, styles, dictionaries, layouts, materials, fields, dynamic blocks, and associative data
- Resilient reads — Optional failsafe recovery with bounded, structured diagnostics and read statistics
- Encoding support — Automatic handling of roughly 40 code pages for pre-2007 drawings
- Optional serialization — Serde support for document data
- Optional 3D imports — STL, COLLADA, OBJ, glTF/GLB, and FBX converted to acadrust documents, including node and parent transforms
- ACAD Arch — Read and preserve AEC classes, construct straight walls, doors, and windows, and edit supported native parameters. See the Arch API
File Version Support
| File code | Release era | DXF | DWG |
|---|---|---|---|
| AC1009 | R11/R12 | R/W | R/W |
| AC1012 | R13 | R/W | R/W |
| AC1014 | R14 | R/W | R/W |
| AC1015 | 2000 | R/W | R/W |
| AC1018 | 2004 | R/W | R/W |
| AC1021 | 2007 | R/W | R/W |
| AC1024 | 2010 | R/W | R/W |
| AC1027 | 2013 | R/W | R/W |
| AC1032 | 2018+ | R/W | R/W |
R/W means read and write support. Entity availability varies by file version.
AC1009 is the shared native DWG format used by AutoCAD Release 11 and Release
12. See the R11/R12 support status for native
fixture coverage and known format limits. DXF export of R11/R12 documents is
promoted to R13 or later.
Examples
use ;
use ;
use ;
use Vector3;
use ;
Requires features = ["import"].
use ;
use ;
Documentation
Development
cargo test
cargo test --all-features
cargo check --all-targets --all-features
GitHub Actions runs these checks with stable Rust on Linux, Windows, and macOS
for pull requests and pushes to main. It also checks default and all-feature
library builds for wasm32-unknown-unknown.
Tests that need drawings which are not in the repository are #[ignore]d,
with the missing file as the reason, so cargo test reports them as ignored.
If you have a file, run its tests with --ignored, for example
cargo test --test table_dwg_read -- --ignored; a test whose file is missing
then fails and names it.
Used By
- Open CAD Studio An open-source (GPLv3) CAD application that uses acadrust as its core native DWG/DXF engine for read/write operations and 3D modeling.
- CADCraft An open-source, AutoCAD-style drafting application written in Rust that uses acadrust for DWG read/write operations.
Support & Sponsorship
If you find this project useful and want to support ongoing maintenance and new features, consider buying me a coffee or becoming a patron!
Every contribution helps keep this project active and well-maintained. Thank you!
License
MPL-2.0 — see LICENSE.