Skip to main content

Module rhino

Module rhino 

Source
Expand description

Rhino models (.3dm, versions 1 to 8).

The format is the openNURBS archive (documented by McNeel’s openNURBS sources, which were read but not copied): a 32-byte header, then nested chunks – a u32 type code and a length (32 bit, 64 bit from version 50). Short chunks (type bit 0x8000_0000) carry their value in the length; chunks with type bit 0x8000 end in a CRC-32. The object table holds one record per object: the class UUID, its data and its attributes.

What is drawn is what Rhino stored for display:

  • mesh objects;
  • the render meshes of polysurfaces (one per B-rep face, saved after the exact geometry unless the file was saved small);
  • the mesh cache of extrusions (Rhino 6 and later);
  • SubD objects, which never store a mesh: their control net is refined by Catmull-Clark subdivision (creases and corners kept) and pushed to the limit surface;
  • block instances: the objects of the block definition, transformed (nested blocks up to MAX_DEPTH);
  • the quantised meshes of Rhino 1 files.

Hidden objects, objects on hidden layers and the objects of block definitions (drawn only through their instances) are left out. Coordinates are converted from the model unit to millimetres.

Everything is bounded: chunk lengths must fit their parent, counts are checked against the bytes left before anything is allocated, the triangles of the whole scene (blocks expanded) are counted against MAX_TRIANGLES before they are copied.

Constants§

MAGIC
The start of the 32-byte header of every .3dm file.
MAX_DEPTH
Nesting of block instances.

Functions§

preview_dib
The preview bitmap Rhino stores in the properties table, as a DIB (BITMAPINFOHEADER + pixels), for files without a 3D preview.
read
Reads a Rhino model into one preview mesh in millimetres.