Skip to main content

Module nxpart

Module nxpart 

Source
Expand description

Siemens NX part files (.prt, NX 1980 and later): the SPLMSSTR stream container.

The format is not documented. This reader only relies on what was verified with the NIST test files in tests/fixtures/cad/nist:

0x00  "SPLMSSTR"
0x11  u64 LE  offset of the FOOTER block
0x19  "HEADER"  u32 count, count × entry
...   stream data
foot  "FOOTER"  u32 count, count × entry
entry u32 LE name length, name (UTF-8 path below /Root/), u64 offset, u64 length

Streams used by TeamCraft:

  • /Root/UG_PART/ExternalReferences, /Root/FastLoad/ExternalReferences: the file names of the components (and the part itself). The rest of the file also keeps history such as Part renamed from "…\old.prt", which is why a scan of the whole file finds false references;
  • /Root/images/preview: the preview image (JPEG).

Folder entries end in / and have no data. Anything that does not fit (short file, entry out of bounds) is skipped, never trusted. Files are read with seeks: only the directory and the requested streams.

Structs§

NxPart
An NX part opened from a file (or any seekable reader).
Stream
A stream of the container: absolute offset and length in the file.

Constants§

JT_STREAM
Stream with the lightweight representation (a JT 9 file after a short index), read by mesh for the 3D preview of parts.
MAGIC
Magic bytes at the start of an NX part.
PREVIEW_STREAM
Stream with the preview image.
REFERENCE_STREAMS
Streams with the names of the referenced component files.

Functions§

data
The data of a stream of an NX part held in memory.
is_nx_part
True if the bytes start like an NX part container.
reference_streams
The data of the reference streams of an NX part (each at most max bytes), or None if it is not an NX part or has none. Each stream starts with the name of the part itself, followed by its components.
reference_streams_in
The reference streams of an NX part held in memory.
streams
The data streams of an NX part held in memory, or an empty list if the bytes are not one. A file cut short keeps the streams inside the bytes.