acadrust
A pure Rust library for reading and writing CAD files (DXF and DWG).
Inspired by ACadSharp. Supports DXF (ASCII & Binary) and DWG (R13–R2018).
Quick Start
[]
= "0.2.10"
use ;
Features
- DXF Read/Write — ASCII and Binary formats, R12–R2018+
- DWG Read/Write — Native binary, R13–R2018 (208/208 roundtrip-perfect)
- 41 Entity Types — Lines, arcs, polylines, hatches, dimensions, 3D solids, viewports, and more
- 3D Solid Creation — ACIS SAT/SAB builder for box, cylinder, cone, sphere, torus, wedge, pyramid
- Paper Space & Layouts — Multiple layouts, viewport-to-layout ownership,
add_layout()API - Tables & Objects — Layers, linetypes, styles, dictionaries, layouts, materials
- Serde Support — Optional
Serialize/Deserializefor all types (features = ["serde"]) - Failsafe Mode — Error-tolerant parsing with structured diagnostics
- Encoding Support — ~40 code pages for pre-2007 files
File Version Support
| Version | AutoCAD | DXF | DWG |
|---|---|---|---|
| AC1009 | R12 | ✅ | — |
| AC1012–AC1014 | R13–R14 | ✅ | ✅ |
| AC1015–AC1032 | 2000–2018+ | ✅ | ✅ |
Examples
use ;
use DwgReader;
use *;
use ;
use ;
use ;
use Vector3;
use ;
Documentation
Full API docs: docs.rs/acadrust
Changelog
0.2.10
- Paper space & layout support —
add_paper_space_entity(),add_entity_to_layout(),add_layout()API for creating viewports in multiple paper space layouts - Correct DXF paper space structure — Active layout (
*Paper_Space) entities in ENTITIES section with code 67; non-active layouts (*Paper_Space0,*Paper_Space1, …) entities inside BLOCK definitions - AutoCAD AUDIT compatibility — Fixed code 67 paper space flag, MLineStyle angle conversion (radians→degrees), AcDbPlotSettings flag, viewport owner handles
- DXF reader — Proper handling of code 67 (paper space flag) in common entity parsing
0.2.9
- ACIS 3DSOLID write support — SAT text builder (R2000–R2007) and SAB binary (R2013+) with primitives: box, wedge, pyramid, cylinder, cone, sphere, torus
SatDocumentbuilder API —add_plane_surface,add_cone_surface,add_sphere_surface,add_torus_surface,add_straight_curve,add_ellipse_curve- 208/208 DWG roundtrip integrity — Zero field drift across 26 entity types × 8 versions
0.2.8
- DWG binary read — Full DWG reader for R13 through R2018
- DWG binary write — Full DWG writer for R13 through R2018
- Handle resolution — Automatic owner handle assignment after read
0.2.7
- Optional serde support —
Serialize/Deserializefor all document types withfeatures = ["serde"] - JSON/YAML round-trip — Full document serialization and deserialization
0.2.6
- 41 entity types — Added MultiLeader, Table, MLine, Mesh, Underlay, Ole2Frame, Wipeout, Shape, and more
- Objects — Dictionaries, Groups, Layouts, MLineStyle, MultiLeaderStyle, TableStyle, PlotSettings, Scale, Materials, VisualStyle, GeoData
- CLASSES section — Full read/write support
- Extended data (XData) — Full support for application-specific extended data
- Reactors & extension dictionaries — Read/write for all entity and object types
0.2.0–0.2.5
- ASCII and Binary DXF read/write
- Core entity types (Point, Line, Circle, Arc, Ellipse, Polyline, LwPolyline, Text, MText, Spline, Dimension, Hatch, Solid, Face3D, Insert, Viewport)
- Table system (Layer, LineType, TextStyle, DimStyle, BlockRecord, AppId, View, VPort, UCS)
- Encoding support (~40 code pages)
- Failsafe reading mode
- Unknown entity preservation
License
MPL-2.0 — see LICENSE.
Acknowledgments
- ACadSharp — the C# library that inspired this project