cadmpeg-step
cadmpeg-step serializes a CadIr document as an ISO 10303-21 exchange file
using the STEP AP214 AUTOMOTIVE_DESIGN schema. It is the library interface for
STEP export; the cadmpeg CLI uses the same model and writer.
Export a document
Add the writer and IR crates:
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 complete Part 21 envelope, product-definition records,
representation context, and reachable boundary-representation geometry. Each IR
region becomes a MANIFOLD_SOLID_BREP; regions with additional shells become
BREP_WITH_VOIDS. The topology walk continues through shells, faces, loops,
coedges, edges, and vertices.
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. 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
StepReport::losses. Review these notes before accepting the file. In
particular:
- faces on unknown surfaces and edges without typed 3D curves are omitted;
- body transforms are not applied, so affected coordinates remain in body-local space;
- coedge pcurves, colors, appearances, source attributes, passthrough records, and parametric history are not emitted;
- procedural geometry is reduced to its solved curve or surface carrier;
- 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. StepError reports
only failures from the output sink. Because output is streamed, an I/O failure
can leave a partial file.
StepReport::entity_counts groups DATA instances by entity keyword, and
StepReport::total_entities gives the complete DATA instance count.
StepReport::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.