skppy.parser.header_parser

Parser for the SketchUp file header.

The header precedes the embedded ZIP archive and encodes product name, version string, and VFF fields.

Entry point:

from skppy.parser.header_parser import parse_header

with open(filepath, "rb") as fh:
    header = parse_header(fh)
raises OldFormatError:

If this ZIP-specific parser receives a legacy pre-ZIP binary format. Use skppy.load() for automatic dispatch.

skppy.parser.header_parser.parse_header(stream: BufferedReader, locate_zip: bool = True) SkpHeader[source]

Parse the SketchUp file header from stream and return a SkpHeader.

Detects two header variants automatically:

  1. Classic header – BOM (0xFF 0xFE or 0xFE 0xFF) followed by length-prefixed UTF-16 product name + version string, then a 10-byte VFF block.

  2. Alternative header – Raw UTF-16-LE string "SketchUp Model {X.Y.Z}\n" without BOM, zero-padded to 64 bytes. The ZIP archive starts immediately after.

Parameters:
  • stream – Open binary file positioned at byte 0.

  • locate_zip – When True, scan ahead to confirm the ZIP signature (PKx03x04) and record the byte offset in SkpHeader.zip_offset.

Returns:

Populated header dataclass.

Return type:

SkpHeader

Raises:
  • EOFError – If the file is too short to contain a valid header.

  • ValueError – If the header bytes cannot be decoded.