cadmpeg-codec-step
cadmpeg-codec-step reads and writes ISO 10303-21 Part 21 exchange structures for
AP203 editions 1–2, AP214, and AP242 editions 1–3. Schema selection uses
StepSchema through StepWriteOptions. StepCodec implements both
Codec decode and Encoder write. The cadmpeg CLI uses the same model.
Support level: L9 for AP242 editions 1–3 and AP203 editions 1–2/AP214.
Install
Decode a Part 21 file
use ;
use StepCodec;
use File;
Decode transfers millimeter-normalized analytic and NURBS geometry, connected solid, sheet, and wire topology with pcurves, product identity and occurrences, AP242 tessellation where present, layers, colors, visibility, and PMI. Named opaque application records retain identity and byte spans when retained.
Write a document
Pass any std::io::Write sink to write_step:
use File;
use BufWriter;
use unit_cube;
use ;
let ir = unit_cube;
let file = create?;
let mut output = new;
let options = StepWriteOptions ;
let report = write_step?;
if !report.losses.is_empty
# Ok::
write_step emits the Part 21 envelope for the selected schema, product and
representation context, and reachable shape. Coverage includes solid, sheet,
and wire bodies plus standalone geometry; coedge pcurves; rigid body placement;
products and occurrences; AP242 tessellation; visibility; layers; named colors;
and semantic or presentation PMI where the target application protocol carries
them. Supported surface carriers are planes, cylinders, cones, spheres, tori,
and rational or non-rational NURBS surfaces. Supported curve carriers are lines,
circles, ellipses, parabolas, hyperbolas, and rational or non-rational NURBS
curves. The writer preserves shared carriers by reusing STEP instances.
Units and metadata
Coordinates are written without rescaling and the representation context declares millimetres. Supply geometry in millimetres before export. The context uses the IR linear tolerance as its uncertainty value; plane and solid angles use radians and steradians.
StepWriteOptions controls FILE_NAME metadata and the target
StepSchema. An empty timestamp produces 1970-01-01T00:00:00, which keeps
default output deterministic. The first body name, when present, supplies the
STEP product name. product_name supplies the FILE_NAME name instead.
Losses and errors
The writer exports representable geometry and records reductions in
ExportReport::losses. Review these notes before accepting the file.
StepUnsupportedPolicy::Report writes the representable subset.
StepUnsupportedPolicy::Reject returns StepError::Unsupported before any
output byte is written.
In particular:
- faces on unknown surfaces and edges without typed 3D curves are omitted;
- non-rigid body transforms and non-identity root occurrence placements report losses;
- coedge pcurves emit their geometry; native-only pcurve metadata is not represented in STEP;
- textures, shaders, source attributes, and retained opaque records report losses or take the refusal path under Reject;
- unsupported procedural definitions emit their solved carrier with a machine-readable loss, or fail under Reject;
- signed sphere radii and nonstandard torus minor radii are normalized where required by the emitted STEP entity.
An empty or fully unrepresentable model still produces a syntactically complete
file with an empty geometric representation and a warning under Report policy.
StepError covers StepError::Unsupported under Reject and
StepError::Io from the output sink. Because output is streamed after the
Reject gate, an I/O failure can leave a partial file.
ExportReport::census groups DATA instances by entity keyword, and
EntityCensus::total gives the complete DATA instance count.
ExportReport::error_count counts loss notes whose severity is at least
Error; lower-severity losses still require caller review.
References
Requires Rust 1.88 or later. Licensed under Apache-2.0.