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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
//! # acadrust
//!
//! A pure Rust library for reading, writing, and inspecting CAD files in DXF
//! (ASCII and binary) and native binary DWG formats. DXF support spans R12
//! through R2018+; DWG support spans R12 through R2018+.
//!
//! ## Highlights
//!
//! - **48 top-level [`EntityType`] variants** for geometry, annotations,
//! dimensions, meshes, solids, regions, bodies, and surfaces.
//! - **ACIS/SAT/SAB** parsing and writing, including solid history and primitive
//! builders.
//! - **Tables and objects** for layers, styles, dictionaries, layouts, fields,
//! materials, and associative data.
//! - **Failsafe reads** with bounded [`ReadDiagnostic`] values and aggregate
//! [`ReadStats`] returned by [`DxfReader::read_with_stats`] and
//! [`DwgReader::read_with_stats`].
//! - **Automatic code-page handling** for older drawings.
//! - Optional Serde serialization and 3D import support.
//! - **ACAD Arch** classes: preserve native AEC records, construct straight
//! walls, doors, and windows, and edit supported parameters. See
//! [`classes::arch`].
//!
//! ## Feature Flags
//!
//! | Feature | Default | Description |
//! |---------|---------|-------------|
//! | `parallel` | Yes | Rayon parallelism for native DWG reading and writing. |
//! | `serde` | No | Enables `serde::Serialize` and `serde::Deserialize` implementations. |
//! | `import` | No | Enables STL, COLLADA, OBJ, glTF/GLB, and FBX importers. |
//!
//! ```toml
//! [dependencies]
//! acadrust = { version = "0.6.7", features = ["serde", "import"] }
//! ```
//!
//! Use `default-features = false` to omit acadrust's Rayon dependency and run
//! DWG work sequentially on the calling thread:
//!
//! ```toml
//! [dependencies]
//! acadrust = { version = "0.6.7", default-features = false }
//! ```
//!
//! Cargo features are additive, so another dependency can enable `parallel`.
//! Applications already disabling default features must explicitly enable
//! `parallel` to retain native parallelism. WebAssembly stays sequential.
//!
//! ## Limit DWG Concurrency
//!
//! With `parallel` enabled on native targets, DWG reads and writes use the
//! current Rayon pool, falling back to Rayon's shared global pool. Add
//! `rayon = "1"` to your application's dependencies, create a pool once, and
//! reuse it for all batches to share a worker limit with acadrust's internal
//! work:
//!
//! ```rust,no_run
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # #[cfg(all(feature = "parallel", not(target_arch = "wasm32")))]
//! # {
//! use acadrust::DwgReader;
//! use rayon::prelude::*;
//!
//! let pool = rayon::ThreadPoolBuilder::new().num_threads(4).build()?;
//! let paths = ["first.dwg", "second.dwg"];
//! let counts: Vec<usize> = pool.install(|| {
//! paths.par_iter().map(|path| {
//! let mut reader = DwgReader::from_file(path)?;
//! let doc = reader.read()?;
//! Ok(doc.entities().count())
//! }).collect::<acadrust::Result<_>>()
//! })?;
//! println!("Entity counts: {counts:?}");
//! # }
//! # Ok(())
//! # }
//! ```
//!
//! Wrap DWG writes in `pool.install` too. Calls outside this pool and separate
//! pools are not covered by its limit. A one-thread pool still uses a Rayon
//! worker; disabling `parallel` keeps acadrust's work on its calling thread.
//!
//! ## Quick Start — DXF
//!
//! ```rust,no_run
//! use acadrust::DxfReader;
//! use acadrust::DxfWriter;
//!
//! # fn main() -> acadrust::Result<()> {
//! let doc = DxfReader::from_file("input.dxf")?.read()?;
//! println!("Entities: {}", doc.entities().count());
//! DxfWriter::new(&doc).write_to_file("output.dxf")?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Quick Start — DWG
//!
//! ```rust,no_run
//! use acadrust::{CadDocument, Color, DwgReader, DwgWriter, EntityType, Line};
//!
//! # fn main() -> acadrust::Result<()> {
//! let mut reader = DwgReader::from_file("input.dwg")?;
//! let doc = reader.read()?;
//! println!("Entities: {}", doc.entities().count());
//!
//! let mut output = 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;
//! output.add_entity(EntityType::Line(line))?;
//! DwgWriter::write_to_file("output.dwg", &output)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Failsafe Reading and Diagnostics
//!
//! Set [`DxfReaderConfiguration::failsafe`] to continue past recoverable
//! record errors. The returned [`ReadOutcome`] contains the document plus
//! source/decode counts and structured diagnostics; strict mode remains the
//! default.
//!
//! ```rust,no_run
//! use acadrust::{DxfReader, DxfReaderConfiguration};
//!
//! # fn main() -> acadrust::Result<()> {
//! let config = DxfReaderConfiguration { failsafe: true, ..Default::default() };
//! let outcome = DxfReader::from_file("drawing.dxf")?
//! .with_configuration(config)
//! .read_with_stats()?;
//! println!("{} entities, {} diagnostics", outcome.stats.output_entities,
//! outcome.stats.diagnostics.len());
//! # Ok(())
//! # }
//! ```
//!
//! ## Optional 3D Imports
//!
//! With `features = ["import"]`, `import_file` auto-detects STL, COLLADA,
//! OBJ, glTF/GLB, and FBX by extension and converts them to a [`CadDocument`].
//!
//! ```rust,no_run
//! # fn main() -> acadrust::Result<()> {
//! # #[cfg(feature = "import")]
//! # {
//! use acadrust::{import_file, ImportConfig};
//!
//! let doc = import_file("model.glb", &ImportConfig::default())?;
//! println!("Imported {} entities", doc.entities().count());
//! # }
//! # Ok(())
//! # }
//! ```
//!
//! ## Serde
//!
//! With `features = ["serde"]`, document types implement Serde traits and can
//! be serialized to JSON using your chosen JSON crate.
//!
//! ```rust,no_run
//! # fn main() -> acadrust::Result<()> {
//! # #[cfg(feature = "serde")]
//! # {
//! use acadrust::{CadDocument, DxfReader};
//!
//! let doc = DxfReader::from_file("drawing.dxf")?.read()?;
//! let json = serde_json::to_string(&doc).unwrap();
//! let restored: CadDocument = serde_json::from_str(&json).unwrap();
//! assert_eq!(restored.entities().count(), doc.entities().count());
//! # }
//! # Ok(())
//! # }
//! ```
//!
//! ## ACAD Arch
//!
//! [`classes::arch`] recognizes AEC, structural, and building-systems classes.
//! A same-version DWG save preserves the native class body. `wall`, `door`,
//! and `window` build an AC1032 drawing from parameters. `decode` reads any
//! Arch class, and supported setters update native parameters together with
//! cached graphics. The calling guide is
//! [src/classes/arch/API.md](https://github.com/hakanaktt/acadrust/blob/main/src/classes/arch/API.md).
//!
//! ## Module Overview
//!
//! | Module | Contents |
//! |--------|----------|
//! | [`document`] | [`CadDocument`] — central drawing container |
//! | [`entities`] | 48 top-level entity variants |
//! | [`entities::modification`] | Entity explosion, mirroring, transforms, and translation |
//! | [`tables`] | Table entries such as [`Layer`] and [`LineType`] |
//! | [`objects`] | Non-graphical objects, dictionaries, layouts, and styles |
//! | [`types`] | Primitives such as [`Vector3`], [`Color`], and [`DxfVersion`] |
//! | [`io`] | DXF, DWG, and optional import readers and writers |
//! | [`entities::acis`] | ACIS/SAT/SAB parsing, writing, and primitive builders |
//! | [`notification`] | Structured parse notifications and recovery counts |
//! | [`classes::arch`] | ACAD Arch entities, objects, constructors, and edits |
//!
//! ## File Version Support
//!
//! | Code | ACAD | 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 |
//!
//! DXF R11/R12 is written as R13 unless requested explicitly with
//! [`DxfWriter::with_version`](io::dxf::DxfWriter::with_version), which emits a
//! genuine R12 file and converts newer entities to R12 entities.
//!
//! `R/W` describes the format-level reader and writer paths. Entity
//! availability varies by file version. See the
//! [R11/R12 support status](https://github.com/hakanaktt/acadrust/blob/main/src/docs/ac1009_support.md)
//! for confirmed AC1009 fidelity gaps. DXF export promotes R11/R12 documents to
//! R13 or later. Compatibility results describe tested fixtures and CAD-engine
//! audits rather than a guarantee for every possible drawing.
// Re-export commonly used types
pub use ;
pub use ;
pub use ;
// Re-export entity types
pub use ;
// Re-export table types
pub use ;
// Re-export document
pub use ;
pub use ;
// Re-export I/O types
pub use ;
pub use ;
pub use ;
pub use RecoverOutcome;
// Re-export ACIS types
pub use primitives;
pub use ;
pub use ;
// Re-export import types (when `import` feature is enabled)
pub use ;
/// Library version
pub const VERSION: &str = env!;