Expand description
Read DWG, DGN (V7/V8), DXF, and CityGML 2.0 files into one format-neutral model, and write DXF, seed-based DGN V8, CityGML 2.0, SVG, and JSON.
let doc = cadkit::open("plan.dgn")?;
for model in &doc.models {
println!("{}: {} entities", model.name, model.entities.len());
}Native, lossless APIs of each format are available under dgn, dwg, dxf, and gml
when the corresponding Cargo features are enabled.
Re-exports§
pub use cadkit_dgn as dgn;pub use cadkit_dwg as dwg;pub use cadkit_dxf as dxf;pub use cadkit_gml as gml;
Modules§
- aci
- AutoCAD Color Index (ACI) to RGB table.
- bytes
- Bounds-checked little-endian reader for untrusted input.
- doc_ops
- High-level in-place
DocumentandEntityoperations: affine transforms, unit conversion, insert explosion, group flattening, curve tessellation, layer filtering, and unused-definition purging. - error
- Error type shared by all cadkit crates.
- export
- Validates resource budgets and float finiteness on in-memory documents before writing.
- geom
- Basic geometry types.
- geom_
ops - Geometry helpers: vector math, affine
Transform, circular/elliptic arcs, polyline bulges and NURBS evaluation. - model
- Format-neutral drawing model.
- ops
- Model traversal and derived properties:
Document::walk,Document::bbox,Entity::resolved_colorandEntityKind::type_name. - options
- Reader options and resource limits.
- polygon
- Bounded validation of closed, planar polygon rings in drawing units.
- prelude
- Ergonomic prelude re-exporting common model, geometry, option, and format types.
- svg
- 2D SVG rendering of a
Document(top view, XY plane). - text
- Text helpers shared by the DXF, DWG, and DGN readers: MTEXT format-code stripping,
\U+XXXX/\M+nXXXXescape decoding, and legacy DOS/OEM single-byte code pages thatencoding_rs(WHATWG) does not include. Panic-free; output size is bounded by the input. - units
- Length-unit helpers: conversion to meters and DWG/DXF
$INSUNITScodes.
Structs§
- Attribute
- Non-graphic data attached to an entity (DWG ATTRIB, DGN tag, item-type property).
- Attribute
Display - Text presentation of a displayed attribute value.
- BBox
- An axis-aligned bounding box.
- Block
- A block definition (DGN: shared cell definition).
- Document
- A complete drawing.
- Entity
- One drawn object.
- Hatch
Loop - One hatch boundary loop.
- Layer
- A layer (DGN: level).
- Limits
- Hard resource limits that protect against malicious or corrupt input. Every reader must check sizes taken from the file against these before allocating or looping.
- Linetype
- A linetype definition.
- Model
- A space that holds drawn entities: model space, a paper-space layout or a DGN model.
- Point3
- A 3D point. 2D data uses
z = 0(or the elevation). - Purge
Stats - Counts of unreferenced definitions removed by
Document::purge_unused. - Raw
- Original bytes of a record, for lossless inspection.
- Read
Options - Options accepted by every reader.
- Schema
Version - Version of the
DocumentJSON layout, serialized as the integerschema_version. - Source
Info - Origin of a
Document. - Summary
- Lightweight header summary returned by header-only
inspectroutines without decoding entity streams. - SvgOptions
- SVG rendering options.
- Text
Style - A text style definition.
- Transform
- A 3x4 affine transform:
p' = x*p.x + y*p.y + z*p.z + t. - Units
- Drawing units.
- Vec3
- A 3D vector (directions, normals, axes).
- Vertex
- Polyline vertex.
- Warning
- A recoverable problem found while reading.
Enums§
- Attachment
- Multi-line text attachment point.
- Color
- Color.
- Dimension
Type - Dimension kind.
- DxfVersion
- DXF output version.
- Entity
Kind - Geometry and type-specific data of an
Entity. - Error
- Why reading or writing failed.
- Format
- File format family.
- Group
Kind - What a
EntityKind::Grouprepresents. - HAlign
- Horizontal text alignment.
- Hatch
Edge - A hatch boundary edge.
- Length
Unit - Length unit. Mirrors the DWG
$INSUNITSset. - Limit
Kind - The limit behind an
Error::LimitExceeded. - Lineweight
- Line weight.
- Model
Kind - Kind of
Model. - VAlign
- Vertical text alignment.
- Value
- A loosely typed value for attributes and props.
Functions§
- detect
- Detects the format of
bytesfrom its header. - inspect
- Inspects a drawing header with default options without decoding full entity streams.
- inspect_
file - Inspects a drawing file header from disk with default options.
- inspect_
file_ with - Inspects a drawing file header from disk.
- inspect_
with - Inspects a drawing header without decoding full entity streams.
- open
- Reads a drawing file from disk with default options.
- open_
with - Reads a drawing file from disk.
- read
- Reads a drawing of any supported format with default options.
- read_
from - Reads a drawing from any
std::io::Readstream, bounded byoptions.limits.max_input_bytes. - read_
with - Reads a drawing of any supported format.
- strip_
dgn_ seed - Copies a single-model DGN V8
seedwithout the drawing content of its model and without the document properties that name people or organisations, for use as the seed ofto_dgn; seedgn::strip_seed_v8. Names in the kept tables (levels, fonts, tag sets, cell definitions) remain and are counted in the report: review them before handing the seed on. The result is not anonymous. - to_
citygml - Writes neutral geometry to generic CityGML 2.0 objects with an explicit CRS and LoD, preserving source coordinates and units without reprojection.
- to_dgn
- Writes a single-model neutral document to DGN V8 using raw seed bytes.
- to_
dgn_ with_ seed - Writes a single-model neutral document to DGN V8 using a pre-parsed
dgn::V8Seed. - to_dxf
- Writes a document as ASCII/UTF-8 DXF text.
- to_
dxf_ bytes - Writes a document as DXF bytes using
options(including optional legacy 8-bit code pages). - to_json
- Serializes a document to JSON.
- to_svg
- Renders a document model as SVG.
- to_
svg_ all_ layers - Renders a document model as SVG, including entities on hidden or frozen layers.
- to_
svg_ bounded - Renders a complete SVG within the output byte and work budgets in
options.include_hidden_layersincludes hidden and frozen layers when true. ReturnsError::LimitExceededrather than a truncated drawing. The byte cap includes all markup and bounds temporary SVG strings during generation; it does not bound the memory already owned by the parsed document. - write_
citygml_ to - Writes neutral geometry to CityGML 2.0 XML into
writer. - write_
dgn_ to - Writes a single-model neutral document to DGN V8 into
writerusing raw seed bytes. - write_
dgn_ with_ seed_ to - Writes a single-model neutral document to DGN V8 into
writerusing a pre-parseddgn::V8Seed. - write_
dxf_ bytes_ to - Writes a document as DXF bytes into
writerusingoptions. - write_
dxf_ to - Writes a document as ASCII/UTF-8 DXF into
writer. - write_
json_ to - Streams a document as JSON directly into
writerwithout buffering a fullString. - write_
svg_ to - Writes an SVG rendering of
docintowriter.