1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
//! # acadrust
//!
//! A pure Rust library for reading and writing CAD files in **DXF** and **DWG** formats.
//!
//! acadrust provides comprehensive support for both file formats with a focus on
//! correctness, type safety, and completeness. Inspired by
//! [ACadSharp](https://github.com/DomCR/ACadSharp), it brings full-featured CAD
//! file manipulation to the Rust ecosystem.
//!
//! ## Highlights
//!
//! - **DXF** — Read and write ASCII and Binary DXF (R12 through R2018+)
//! - **DWG** — Read and write native DWG binary files (R13 through R2018+)
//! - **41 entity types**, 9 table types, 20+ non-graphical objects
//! - **ACIS/SAT/SAB** — Parse and write ACIS solid-model data (SAT text and SAB binary);
//! parametric primitive builders for box, wedge, pyramid, cylinder, cone, sphere, and torus
//! - **Type safe** — strongly-typed entities, tables, and enums
//! - **Failsafe mode** — error-tolerant parsing that collects diagnostics
//! - **Encoding support** — automatic code page detection for pre-2007 files
//! - **Serde support** — optional `Serialize`/`Deserialize` for all types (enable the `serde` feature)
//!
//! ## Feature Flags
//!
//! | Feature | Description |
//! |---------|-------------|
//! | `serde` | Enables `serde::Serialize` and `serde::Deserialize` on all document types |
//!
//! ```toml
//! [dependencies]
//! acadrust = { version = "0.3.4", features = ["serde"] }
//! ```
//!
//! ### Serialize an entity to JSON
//!
//! ```rust,ignore
//! use acadrust::entities::Line;
//!
//! let line = Line::from_coords(0.0, 0.0, 0.0, 100.0, 50.0, 0.0);
//! let json = serde_json::to_string_pretty(&line).unwrap();
//! println!("{json}");
//! ```
//!
//! ### Round-trip a full document
//!
//! ```rust,ignore
//! use acadrust::{CadDocument, DxfReader};
//!
//! let doc = DxfReader::from_file("input.dxf")?.read()?;
//!
//! // Serialize
//! let json = serde_json::to_string(&doc).unwrap();
//!
//! // Deserialize
//! let doc2: CadDocument = serde_json::from_str(&json).unwrap();
//! assert_eq!(doc2.entities().count(), doc.entities().count());
//! ```
//!
//! See the [`examples/serde_json.rs`](https://github.com/hakanaktt/acadrust/blob/main/examples/serde_json.rs)
//! example for more patterns including web-API-style entity lists.
//!
//! ## Quick Start — DXF
//!
//! ```rust,ignore
//! use acadrust::{CadDocument, DxfReader, DxfWriter};
//!
//! // Read
//! let doc = DxfReader::from_file("input.dxf")?.read()?;
//! println!("Entities: {}", doc.entities().count());
//!
//! // Write
//! DxfWriter::new(&doc).write_to_file("output.dxf")?;
//! # Ok::<(), acadrust::error::DxfError>(())
//! ```
//!
//! ## Quick Start — DWG
//!
//! ```rust,ignore
//! use acadrust::{CadDocument, DwgWriter};
//! use acadrust::io::dwg::DwgReader;
//! use acadrust::entities::*;
//! use acadrust::types::{Color, Vector3};
//!
//! // Read
//! let mut reader = DwgReader::from_file("input.dwg")?;
//! let doc = reader.read()?;
//!
//! // Create and write
//! let mut doc = CadDocument::new();
//! let mut line = Line::from_coords(0.0, 0.0, 0.0, 100.0, 50.0, 0.0);
//! line.common.color = Color::RED;
//! doc.add_entity(EntityType::Line(line))?;
//! DwgWriter::write_to_file("output.dwg", &doc)?;
//! # Ok::<(), acadrust::error::DxfError>(())
//! ```
//!
//! ## Module Overview
//!
//! | Module | Contents |
//! |--------|----------|
//! | [`document`] | [`CadDocument`] — the central drawing container |
//! | [`entities`] | 41 graphical entity types ([`Line`], [`Circle`], [`Spline`], …) |
//! | [`tables`] | Table entries ([`Layer`], [`LineType`], [`TextStyle`], [`DimStyle`], …) |
//! | [`objects`] | Non-graphical objects (dictionaries, layouts, styles) |
//! | [`types`] | Primitives ([`Vector3`], [`Color`], [`Handle`], [`DxfVersion`], …) |
//! | [`io`] | Readers and writers for DXF and DWG |
//! | [`entities::acis`] | ACIS/SAT/SAB solid-model parser, writer, and primitive builders |
//! | [`classes`] | DXF class definitions (CLASSES section) |
//! | [`xdata`] | Extended data (XData) attached to entities |
//! | [`error`] | Error types ([`DxfError`]) and [`Result`] alias |
//! | [`notification`] | Structured parse diagnostics |
//!
//! ## File Version Support
//!
//! | Code | AutoCAD | DXF | DWG |
//! |------|---------|-----|-----|
//! | AC1009 | R12 | 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 |
// Re-export commonly used types
pub use ;
pub use ;
// Re-export entity types
pub use ;
// Re-export table types
pub use ;
// Re-export document
pub use CadDocument;
// Re-export I/O types
pub use ;
pub use ;
// Re-export ACIS types
pub use ;
pub use ;
pub use primitives;
// Re-export import types (when `import` feature is enabled)
pub use ;
/// Library version
pub const VERSION: &str = env!;