Skip to main content

Crate cadkit

Crate cadkit 

Source
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 Document and Entity operations: 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_color and EntityKind::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+nXXXX escape decoding, and legacy DOS/OEM single-byte code pages that encoding_rs (WHATWG) does not include. Panic-free; output size is bounded by the input.
units
Length-unit helpers: conversion to meters and DWG/DXF $INSUNITS codes.

Structs§

Attribute
Non-graphic data attached to an entity (DWG ATTRIB, DGN tag, item-type property).
AttributeDisplay
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.
HatchLoop
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).
PurgeStats
Counts of unreferenced definitions removed by Document::purge_unused.
Raw
Original bytes of a record, for lossless inspection.
ReadOptions
Options accepted by every reader.
SchemaVersion
Version of the Document JSON layout, serialized as the integer schema_version.
SourceInfo
Origin of a Document.
Summary
Lightweight header summary returned by header-only inspect routines without decoding entity streams.
SvgOptions
SVG rendering options.
TextStyle
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.
DimensionType
Dimension kind.
DxfVersion
DXF output version.
EntityKind
Geometry and type-specific data of an Entity.
Error
Why reading or writing failed.
Format
File format family.
GroupKind
What a EntityKind::Group represents.
HAlign
Horizontal text alignment.
HatchEdge
A hatch boundary edge.
LengthUnit
Length unit. Mirrors the DWG $INSUNITS set.
LimitKind
The limit behind an Error::LimitExceeded.
Lineweight
Line weight.
ModelKind
Kind of Model.
VAlign
Vertical text alignment.
Value
A loosely typed value for attributes and props.

Functions§

detect
Detects the format of bytes from 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::Read stream, bounded by options.limits.max_input_bytes.
read_with
Reads a drawing of any supported format.
strip_dgn_seed
Copies a single-model DGN V8 seed without the drawing content of its model and without the document properties that name people or organisations, for use as the seed of to_dgn; see dgn::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_layers includes hidden and frozen layers when true. Returns Error::LimitExceeded rather 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 writer using raw seed bytes.
write_dgn_with_seed_to
Writes a single-model neutral document to DGN V8 into writer using a pre-parsed dgn::V8Seed.
write_dxf_bytes_to
Writes a document as DXF bytes into writer using options.
write_dxf_to
Writes a document as ASCII/UTF-8 DXF into writer.
write_json_to
Streams a document as JSON directly into writer without buffering a full String.
write_svg_to
Writes an SVG rendering of doc into writer.

Type Aliases§

Props
Format-specific extra data, keyed "<format>.<name>" (e.g. "dgn.level_id").
Result
Result alias using Error.