cadmpeg-codec-nx 0.3.0

Read Parasolid geometry and topology from NX .prt files.
Documentation

cadmpeg-codec-nx

cadmpeg-codec-nx reads Siemens NX .prt files stored as SPLMSSTR containers into CadIr. It detects the container by its SPLMSSTR signature, extracts zlib-compressed Parasolid neutral-binary streams from the canonical part payload, and decodes supported geometry and topology. It does not read Creo files, which also use the .prt extension.

Support level: L4 for single-body, RMFastLoad-selected, and terminal-lineage-resolved body images; L2 for unresolved multi-partition history.

cargo add cadmpeg-codec-nx cadmpeg-ir
use cadmpeg_codec_nx::NxCodec;
use cadmpeg_ir::{Codec, DecodeOptions};
use std::fs::File;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut input = File::open("part.prt")?;
    let result = NxCodec.decode(&mut input, &DecodeOptions::default())?;

    println!(
        "{} bodies, {} surfaces",
        result.ir.model.bodies.len(),
        result.ir.model.surfaces.len()
    );
    Ok(())
}

The result contains the decoded model in result.ir and a DecodeReport in result.report. Check the report before treating the model as complete. It records missing topology, unresolved edit overlays, unsupported entity families, and NX metadata that was not transferred.

Call NxCodec::inspect when you need container metadata without entity decode. It lists SPLMSSTR directory entries and classifies embedded streams as partition, deltas, plain cached body, or preview data. Set DecodeOptions::container_only to produce metadata IR without decoding entities.

Data model and coverage

NX stores part geometry in one or more Parasolid streams inside an SPLMSSTR container. The decoder inflates each stream, converts Parasolid metre values to the millimetre-based IR, and retains the inflated stream as an unknown record for provenance and passthrough.

Supported typed geometry includes points; planes, cylinders, cones, spheres, and tori; lines, circles, and ellipses; NURBS curves and surfaces; and selected trimmed curves. The decoder builds body, region, shell, face, loop, coedge, edge, and vertex topology when its fixed-record references resolve. Geometry that cannot be attached remains available through derived free topology.

Partition and adjacent equal-schema deltas streams are scanned together. Exactly keyed full records and tombstones use the last event for each key. Unmatched tombstones remain unresolved. Segment body aliases, primary-body writers, and Boolean tool operands select terminal partition images when the complete body lineage is unambiguous. Assembly files can contain only external child-part references and therefore produce no inline geometry.

Ordered feature-operation records, body dependencies, Boolean operations, sketch record lanes, arrangements, part attributes, and numeric expressions transfer. Complete design history, assembly occurrence placement, materials, appearances, entity-owned attributes, tessellation, and native .prt writing are not supported. See the format support matrix for current coverage and the format notes for byte semantics.

The crate also exposes lower-level container, stream, geometry, NURBS, and topology modules for tools that need inspection or partial decoding. Most applications should use NxCodec.

Requires Rust 1.88 or later. Licensed under Apache-2.0. See the API documentation, repository, and clean-room and legal policy.

Siemens NX and Parasolid and other product names are trademarks of their respective owners. cadmpeg uses them only to identify the file formats this codec targets and is not affiliated with, endorsed by, or sponsored by any CAD vendor. See the clean-room and legal policy.