Skip to main content

Module catprod

Module catprod 

Source
Expand description

CATIA V5 products (.CATProduct): which documents are placed where (see docs/src/research/catia-product-structure.md).

  • Every CATIA document lists its containers near the start of the file:

    02 00 81 20 | u32 n | name \0 | type \0 | up to 8 × 00
    | 03 00 f7 00 03 00 00 00 | uuid (4 × u32 big-endian)

    Products refer to a component by the UUID of its container named CATProdCont – no file name is stored (document).

  • The product’s own CATProdCont is an object stream (OSMX) of sections 7c <kind> <u32 length from the 7c>: header 0c, objects 04, one side block per object 08, extensions 0b, strings 02. Small numbers are 81..cf (− 0x81), d1..e3 xx or 80 <u32>; a string reference is 34..ff (− 0x34) or 32 <u32 index + 1>; doubles are e6 <f64>, e7 / e8 / e9 (1, 0, −1).

  • An object (7c 05) has a header 7c 06 (two flag bytes, class, name, ea <u32 id>) and attributes 7c 07: <name> <key> e8|e9 <flags> <type> [byte after e9] 37 <value> fe (type 12: a string, 07: <n> <0> n doubles).

  • An instance is an ASMPRODUCT with _InstanceName; its name is the part number. Its side block holds the link to the referenced document (e5 <u32 length> 11 03 <uuid> …) and the list _BagRepsList, whose PRDBAGREP carries _Position: X, Y and Z axis and origin (mm) of the instance in the product. Without it the instance sits at the origin.

Everything is read defensively: every length is checked against the bytes that are left, and an instance that does not add up is left out, never a panic. No CATIA code or documentation was used.

Constants§

HEAD
The container table lies in the first bytes of the file.
MAX_PRODUCT
Largest product read.

Functions§

components
The instances of a product (the whole file): name = part number, document = UUID of the referenced document. None when it is no CATIA product.
containers
The containers of a CATIA document: (name, type, UUID).
document
The UUID products refer to this document by (its container named CATProdCont), from the first HEAD bytes of a CATIA file.
document_of
document of a file (reads only its first bytes).
kind_of
What a product file holds: its instances, or Kind::Other.
uuid_text
The text form of a container UUID, as CATIA names its containers (Cont_<uuid>): hhhhhhhh_h_hhhhhhhh_h.

Type Aliases§

SampleInstance
An instance of [sample]: part number, UUID of the referenced document, placement (X, Y, Z axis and origin) or None.