← back to pin list

Reading an .ai by named layer — mvt_layers.py

kerfmaster pin list · Preflight — how files come in

recordStates what the code does today. Auditable against the code — this is the only type that can go stale.

Content last changed 2026-08-07 — computed from the item itself, not typed.

Contract — Intake stage

This contract describes the code as it runs today.

takes vector ?

makes contours ?

fails if Quoting a part size that is really the artboard clip; reading a layered .ai as one flat drawing.

Contract last changed 2026-08-07 — computed, not typed. Dated separately from the text above, so neither date can speak for the other.

mvt_layers.py splits an Illustrator content stream on its /OC /MCn BDC … EMC marks, maps each MCn to its OCG /Name, and returns [(layer name, [element])] where an element is one filled path: its outer subpath plus the subpaths that are holes in it. python3 mvt_layers.py <file.ai> [width_in] prints the inventory.

Two traps it handles, both hit on the MVT template

The artboard clip. Every layer's stream opens with 0 792 612 -792 re W n. Left in, it merges with the first real element and the file reports a 103 × 134 in part. It is dropped by matching the page box.

Subpath order is Illustrator's, not ours. The first subpath of an element is often a hole — on this file the bracket's first subpath is a 1.08 × 0.11 in slot. The outer is the biggest subpath by area, never the first.

What it read on 1786070312 (MVT mounting template)

Four layers. Layer 2 — the artwork, three elements: cloud 28.72 × 17.69 in / 332.88 in², ring 14.10 in dia / 68.49 in² net, triangle 6.77 × 7.65 in / 29.59 in². Those are option C's three plates. test — three elements: a bracket 25.31 × 17.95 in, 164.94 in² gross with 56 slots taking 8.90 in² out, 156.04 in² net; the positioning outline, a band 29.98 × 22.28 in, 51.27 in²; and a stray 0.108 in dot. Layer 1 — the same three, but its outline band is 61.43 in²: 10.16 in² more, because it has not been trimmed clear of the bracket. Layer 3 — 159 filled dots forming four dotted indication patches, not geometry.

Two measurements that say what the bracket is for. 0.00 in² of it lies outside cloud ∪ ring ∪ triangle — it is completely hidden behind the artwork by design. And 0.00 in² of the outline band overlaps it on layer test, against 10.16 in² on Layer 1: test is the trimmed version.

Slot widths measured on the minimum rotated rectangle: 0.075, 0.111 and 1.319 in; lengths 0.08 to 3.22 in. The two narrow families are under the 0.125 in material thickness and under the 0.150 in pierce standoff, so they are a cutability question before they are anything else.