altium monkey v2026.11.26 · gobblerito
On This Page (8)

Gerber Contract

altium-monkey writes Gerber files from the board's Fab view: board.fab(...).to_gerbers(...) or the one-call shortcut board.to_gerbers(...). Output conforms to the Ucamco Gerber Layer Format Specification 2026.05 (section numbers below refer to that specification).

The Gerber writer only lowers the normalized FabView: it does not reinterpret board records. to_gerbers() draws the board view once per file set and writes each layer, pad master, drill guide, drill drawing, and PROFILE film from it. On manufacturing layers (copper, solder mask, paste, legend, profile, drill), artwork matches Altium's Gerber output except where Altium's form is deprecated or breaks the specification. See Matching Altium's form for comparison options.

Defaults

Matching Altium's Form

Use these options only when comparing output directly against Altium Designer's Gerber files (the defaults are recommended for fabrication; fewer than 6 decimals is deprecated):

OptionPython keywordEffect
Plain Gerber (X1)x2_attributes=FalseEmit no X2 attributes (AOD-004)
Altium's griddecimal_digits=4%FSLAX44Y44*% (100 nm grid; deprecated per section 8.2.1.3)
Altium's missing dotsdegenerate_strokes="omit"Omit zero-length strokes (AOD-001)

File Attributes

Each Gerber header carries %TF...*% file attributes:

AttributeValue
.FileFunctionDerived from layer role, side, and physical copper index: Copper,L<n>,Top|Inr|Bot (,Plane on planes), Soldermask,Top|Bot, Paste,Top|Bot, Legend,Top|Bot, Pads,Top|Bot, Drillmap, Profile,NP, OtherDrawing,<layer name>, or Other,<layer name>. Copper layers without a copper_index emit gerber_file_function_unknown.
.FilePolarityPositive; Negative for solder mask films (showing openings) and negative plane films.
.SameCoordinatesOne shared GUID per to_gerbers() call unless overridden via same_coordinates.
.GenerationSoftwareWavenumber,altium-monkey,<version> using altium_monkey.__version__.
.CreationDateISO 8601 UTC timestamp (or explicit creation_date with timezone), shared across all files in the set.

Object Attributes

AttributeApplied to
.AperFunctionCopper pads by role (SMDPad,CuDef, OtherPad,InnerSMD, ComponentPad, WasherPad, ViaPad, OtherPad,Unknown); plane antipads (AntiPad) and thermal reliefs (ThermalReliefPad); copper text (NonConductor); other copper (Conductor); mask/paste/legend (Material); profile (Profile).
.NEvery copper object: net name (empty for unassigned).
.POuter copper pad lands belonging to a component: <designator>,<pin>.
.CEvery component land on any layer: component designator.

Field values are escaped per section 3.4.3 (\uXXXX for delimiters, escape characters, and non-ASCII characters) so files remain pure ASCII. Object attributes are cleared with %TD<name>*% except .C, where %TD*% clears the dictionary before re-applying retained attributes for strict Ucamco parser compatibility (section 3.5).

Pad Forms

On copper and pad-master films, every pad or via land is a single flash. Aperture macros are preferred over block apertures (AB) for broad CAM compatibility:

Land shapeWritten as
RoundCircle aperture C
Round with round hole (annulus)Circle aperture C with hole
Axis-aligned rectangleRectangle aperture R
Axis-aligned capsule (oval)Obround aperture O
Rotated rectangle or polygon (≤ 5,000 vertices)Aperture macro of outline primitives (code 4), holes with exposure off
Rounded rectangle, rotated capsule, convex equal-radius polygonExact aperture macro: corner circles (code 1), edge vector lines (code 20), and centre outline (code 4)
Custom pad with arcs, or polygon > 5,000 verticesBlock aperture (AB) holding the pad's region

Non-pad copper (apart from plane antipad/relief flashes) is drawn with regions or strokes. Solder mask, paste, and legend openings are flashed when round or rectangular.

Regions & Contour Hygiene

Every region exterior is emitted as a spec-compliant simple contour (section 4.10.3):

Virtual Layers & Custom Extensions

to_gerbers() also supports selective film toggles (keepout, profile, pad_masters, drill_guide, drill_drawing, mechanical_layers), dual-key custom extensions (accepting either canonical FabView layer keys like "TOP", "PROFILE", "CUTOUTS" or Altium default extensions like "GTL", "GM", "GCU"), profile_cutouts=True (drawing hatched "CUTOUT" callouts on .GM), and all 17 board-derived virtual_layers (.GCU, .GP1T/.GP1B, .GDT/.GDB, .GCT/.GCB, .GLT/.GLB, .GRT/.GRB, .GAT/.GAB, .GADT/.GADB, .GPLT/.GPLB). All virtual layers lower as monochrome positive Gerber geometry with %TF.FileFunction,OtherDrawing,<layer name>*% (e.g., OtherDrawing,Top Component Outlines, OtherDrawing,Top Component Designators). See Virtual Fab Layers for the full option contract.

Validation

Generated Gerber files are verified against a strict Ucamco 2026.05 grammar checker, read back against the board's FabView within 100 nm, and compared against Altium Designer reference captures across synthesized and real-world boards.

altium-monkey v2026.11.26 · gobblerito·Docs updated 2026.11.29 17:55 UTC (0665053)