On This Page (20)
- Why FabView Exists
- Quick Start
- Tier 1 Context Options (board.fab(...))
- Working With FabOutput And FabFile
- Output Guides
- Gerber (to_gerbers)
- NC Drill (to_nc_drill)
- IPC-2581B (to_ipc2581)
- PCB & Footprint SVG (to_svg, to_layer_svgs)
- Pick & Place (to_pnp) And PCB BOM (to_bom)
- Panels And Embedded Board Arrays
- Child Board Resolution
- Flattened Copies vs. StepRepeat
- Panel Assembly Options (panel={...})
- Custom Lowerings With fab.view()
- View Switches & Output Usage Table
- Layer Keys
- Core Query Methods On FabView
- Practical Notes For Python Users
- Runnable Examples
Fab & FabView
Fab and FabView are the unified PCB fabrication and board-rendering surface in altium-monkey. Call board.fab(...) (or Fab(board, ...)) to create a Fab context once, then emit Gerber X2/X1, NC Drill, IPC-2581B, PCB SVG, Pick and Place CSV, and PCB BOM CSV — or query the normalized board geometry directly with fab.view(...).
Why FabView Exists
Before FabView, each PCB output (SVG, Gerber, IPC-2581, Pick and Place, BOM) re-interpreted .PcbDoc records on its own code path. Rules, pad stacks, solder-mask expansions, plane reliefs, panel copies, special strings, and TrueType fonts could subtly diverge between a board's SVG preview, its Gerbers, and its IPC-2581 package.
FabView fixes this by normalizing the board once through Altium's own rules and sharing that draw stage across every output of a Fab instance:
┌────────────────────┐
│ AltiumPcbDoc │
│ + PrjPcb / Fonts │
└─────────┬──────────┘
│ board.fab(**context)
▼
┌────────────────────┐
│ Shared FabView │
│ (rules, stackup, │
│ lands, pours, │
│ planes, fonts, │
│ variants, copies) │
└───┬───┬───┬───┬───┬┘
┌────────────────┘ │ │ │ └────────────────┐
▼ ▼ ▼ ▼ ▼
to_gerbers() to_nc_drill() to_ipc2581() to_svg() /
(Gerber X2/X1) (Excellon + (IPC-2581B to_layer_svgs()
board rout) .cvg XML) to_pnp() / to_bom()Key design rules:
- Single draw stage: Every writer formats normalized
FabViewdata; no writer re-reads.PcbDocrecords or computes its own expansions. - Shared work: Calling
fab.to_gerbers(),fab.to_nc_drill(),fab.to_ipc2581(), andfab.to_svg()on the sameFabreuses one draw of the board. - In-memory first: Every
to_*method returns aFabOutputin memory. Nothing touches disk until you calloutput.write(directory). - Best-effort on real boards: Unresolved special strings, missing fonts, or unsupported geometry are recorded in
output.diagnosticswhile the rest of the board still writes. Caller errors (invalid options, missing input files, or existing target files withoutoverwrite=True) still raise. - Designed for future formats (ODB++ planned): ODB++ export is planned for a future release and is not included in this release.
FabViewwas intentionally designed with ODB++ in mind — normalized stackups, plane films, padstacks, component packages, nets, drill spans, and panel step trees are already modeled in the view so the upcoming ODB++ writer will lower directly from the same sharedFabViewalongside Gerber, NC Drill, and IPC-2581B.
Quick Start
from altium_monkey import AltiumPcbDoc
board = AltiumPcbDoc.from_file("board.PcbDoc")
# Tier 1: fix board inputs once (auto-discovers the PrjPcb listing this board)
fab = board.fab(variant="A")
# Tier 2: emit multiple outputs from the same shared draw
gerbers = fab.to_gerbers()
drill = fab.to_nc_drill()
ipc = fab.to_ipc2581(merge_net_ties=True)
svg = fab.to_svg(hidden_component_texts="draw")
pnp = fab.to_pnp(units="mm")
bom = fab.to_bom()
# Inspect diagnostics before writing
for diag in gerbers.diagnostics:
print(diag.severity, diag.code, diag.message)
# Write to disk (raises FileExistsError if a file already exists unless overwrite=True)
gerbers.write("out/gerber")
drill.write("out/gerber")
ipc.write("out/ipc2581")
svg.write("out/svg")
pnp.write("out/assembly")
bom.write("out/assembly")For single-output scripts, AltiumPcbDoc provides one-call shortcuts that accept Tier 1 (ContextOptions) and Tier 2 output keywords together:
board.to_gerbers(**options)board.to_nc_drill(**options)board.to_ipc2581(**options)board.to_svg(**options)board.to_layer_svgs(**options)board.to_pnp(**options)board.to_bom(**options)
Fab(board, **context) accepts the same Tier 1 keyword options as board.fab(**context).
Tier 1 Context Options (board.fab(...))
All options are keyword-only. An unknown keyword raises TypeError; an invalid value raises ValueError.
| Option | Default | Meaning |
|---|---|---|
project | auto-discovered | Path to .PrjPcb; when omitted, searches the board's folder and parent folders for a .PrjPcb listing the board (fab.project) |
parameters | {} | Project parameter overrides (dict[str, str]) for .Name special strings |
variant | None | Variant name; None draws [No Variations] |
moment | None | ISO 8601 local timestamp for .Print_Date and .Print_Time |
build_number | None | Value for .Application_BuildNumber (AOD-068) |
fonts | {} | TrueType font settings (policy, files, folders, standard_only); see Text & Font Rendering |
mask_shapes_without_region | "draw" | Draw pad mask/paste shapes without a board region (AOD-008); "omit" matches Altium |
backdrill_start_lands | "draw" | Draw back-drill start lands and mask openings (AOD-014); "omit" matches Altium |
keepout_texts | "omit" | Omit Keepout-flagged texts off the Keep-Out layer (AOD-042); "draw" matches Altium |
omit_drilled_away_inner_lands | False | Omit inner lands of non-plated pads whose round hole is at least as wide as the land |
Inspect fab.project for the resolved .PrjPcb path, fab.context for the decoded context options, and fab.diagnostics for project-discovery warnings (project_not_found, project_ambiguous, project_unreadable).
Working With FabOutput And FabFile
Every to_* method returns a FabOutput, which is a read-only Mapping[str, FabFile] ordered by file name:
gerbers = fab.to_gerbers()
print(gerbers.status) # "written", "partial", or "empty"
for name, file in gerbers.items():
print(name, file.key, file.role, file.status, file.count, len(file.data))
# Access text directly (decoded with file.encoding: utf-8 by default, cp1252 for PnP/BOM CSVs)
top_gerber = gerbers["board.GTL"].text
# Single-file outputs (to_ipc2581, to_pnp, to_bom) whose filename depends on board stem / variant:
pnp_file = next(iter(fab.to_pnp().values()))
print(pnp_file.name, pnp_file.encoding) # e.g. "Pick Place for board.csv", "cp1252"
csv_text = pnp_file.text
# Check files intentionally skipped for used layers
for skipped in gerbers.omitted:
print(skipped.output, skipped.files, skipped.reason)FabOutput.write(directory, *, overwrite=False) creates directory, checks that no target file exists before writing anything (raising FileExistsError unless overwrite=True), skips status == "unavailable" entries, and returns the written tuple[Path, ...].
Output Guides
Gerber (to_gerbers)
Writes the board's full Gerber file set as Altium's reference OutJob names it (.GTL, .GBL, .G1…, .GP1…, .GTS, .GBS, .GTP, .GBP, .GTO, .GBO, .GM1…, .GKO, .GD1…, .GG1…, .GM profile), plus any requested board-derived virtual layers (.GCU, .GP1T/.GP1B, .GDT/.GDB, .GCT/.GCB, .GLT/.GLB, .GRT/.GRB, .GAT/.GAB, .GADT/.GADB, .GPLT/.GPLB). Defaults conform to Ucamco Gerber Layer Format Specification 2026.05 (X2 attributes on, 6 decimal places of a millimetre — a 1 nm grid, every copper pad flashed).
Key options (GerberOptions from altium_monkey.fab / FabGerberOptions from altium_monkey.fab_view_contracts.generated, plus keyword-only virtual_options):
| Option | Default | Meaning |
|---|---|---|
x2_attributes | True | Emit Gerber X2 %TF/%TA attributes (False writes plain X1, AOD-004) |
decimal_digits | 6 | Millimetre decimal places (0–9; 4 matches Altium's 100 nm grid) |
datum | "user" | "user" (board origin) or "absolute" (source zero) |
offset_nm | (0, 0) | Additional (x, y) output offset in nanometres |
stem | board stem | File name stem |
same_coordinates | auto GUID | Shared .SameCoordinates GUID across the file set |
creation_date | now (UTC) | ISO 8601 timestamp with timezone for .CreationDate |
degenerate_strokes | "draw" | "draw" emits zero-length strokes as disks (AOD-001); "omit" matches Altium |
unconnected_inner_lands | "draw" | Currently only "draw" is supported ("omit" raises ValueError pending reference captures) |
keepout | True | Emit the Keep-Out layer film (.GKO) |
profile | True | Emit the board profile film (.GM) |
pad_masters | True | Emit top/bottom pad master films (.GPT, .GPB) |
drill_guide | True | Emit per-drill-pair drill guide films (.GG<n>) |
drill_drawing | True | Emit per-drill-pair drill drawing films (.GD<n>) |
mechanical_layers | Altium OutJob plot set | Absent reproduces Altium's Mechanical 1..32 plot set; [] writes none; ["used"] writes every enabled/used mechanical layer; explicit selectors (["MECHANICAL8", "GM13", "15"]) write only those layers |
extensions | {} | Dual-key custom extension overrides (dict[str, str]): keys accept either canonical FabView layer keys ("TOP", "PROFILE", "KEEPOUT", "MECHANICAL8", "MID1", "PLANE1", "DRILLGUIDE1", "CUTOUTS") or Altium default extensions ("GTL", "GM", "GKO", "GM8", "G1", "GP1", "GG1", "GCU"); leading . is stripped |
virtual_layers | () | Additional virtual layers to lower as Gerber files (all 17 canonical keys: "CUTOUTS", "PIN1_TOP/BOTTOM" or alias "POLARITY_TOP/BOTTOM", "DIODES_TOP/BOTTOM", "CAPACITORS_TOP/BOTTOM", "INDUCTORS_TOP/BOTTOM", "RESISTORS_TOP/BOTTOM", "ASSEMBLY_OUTLINES_TOP/BOTTOM", "ASSEMBLY_DESIGNATORS_TOP/BOTTOM", "PAD_LABELS_TOP/BOTTOM") |
profile_cutouts | False | Draw hatched "CUTOUT" callout labels directly on the .GM profile film instead of solid-filling interior cutouts |
virtual_options | None | Optional VirtualLayerOptions configuring fonts (font_mode, stroke_font, font_family), visibility, cutouts, Pin 1 styles & knockout, diodes, capacitors, inductors, resistors, assembly outlines, assembly designators, and pad labels (see Virtual Fab Layers) |
from altium_monkey.fab import CutoutLayerOptions, VirtualLayerOptions
gerbers = fab.to_gerbers(
keepout=True,
profile=True,
pad_masters=False,
drill_guide=False,
drill_drawing=True,
mechanical_layers=["used"],
extensions={
"PROFILE": "GKO_OUTLINE", # canonical FabLayerKey
"GTO": "GTO_TOP_SILK", # Altium default extension key
"CUTOUTS": "GCU", # virtual layer key
},
virtual_layers=("CUTOUTS", "PIN1_TOP", "DIODES_TOP", "ASSEMBLY_OUTLINES_TOP"),
profile_cutouts=True,
virtual_options=VirtualLayerOptions(
cutouts=CutoutLayerOptions(hatch_pitch_mm=1.0, label="CUTOUT"),
),
)See the Gerber contract for attribute rules, pad aperture forms, and region contour hygiene, and Virtual Fab Layers for full VirtualLayerOptions details.
NC Drill (to_nc_drill)
Writes Excellon drill files per drill pair (.TXT / .TX1… split by plated and non-plated, round, slot, square, rect, and counterhole files) and the board-edge rout when enabled.
Key options (NcDrillOptions):
| Option | Default | Meaning |
|---|---|---|
stem | board stem | File name stem |
datum | "user" | "user" or "absolute" |
offset_nm | (0, 0) | Additional (x, y) offset in nanometres |
decimal_digits | 4 | Millimetre decimal places (Altium's 4:4 grid) |
board_edge_rout | True | Emit board-edge rout file (from the view's ROUT key; role="board_edge_rout") |
board_edge_rout_tool | 5080000 | Board-edge rout tool diameter in nm (Altium's 200 mil default) |
Each drill FabFile sets role ("round", "slot", "square", "rect", "board_edge_rout", "counterhole"), plated, and span (layer-name pair).
IPC-2581B (to_ipc2581)
Writes a single schema-valid IPC-2581 Rev B XML document (<stem>.cvg) from the board's saved-geometry FabView, preserving native contours with cutouts, stroke line caps, per-owner padstacks, packages, <Bom>/<Avl> BOM items, non-electrical document layers (KEEPOUT, MECHANICAL<n>, DRILLDRAWING<n>), and multi-level StepRepeat panel steps.
Key options (Ipc2581Options from altium_monkey.fab / FabIpc2581Options from altium_monkey.fab_view_contracts.generated, plus keyword-only virtual_options):
| Option | Default | Meaning |
|---|---|---|
stem | board stem | Output file stem (<stem>.cvg) and root step name |
creation_date | now (UTC) | ISO 8601 history timestamp with timezone |
degenerate_strokes | "draw" | "draw" (AOD-001) or "omit" |
outline_arcs | "exact" | Slot cavity arcs: "exact" true arcs or "altium_chords" |
merge_net_ties | False | Merge nets joined by Net Ties (Altium's MergeNetTieNets) |
negative_standoffs | "zero" | "zero" clamps negative standoffs to 0 for schema validity (AOD-021); "as_saved" matches Altium |
edge_cutouts | "fold" | Cutouts touching/crossing the board edge: "fold" as notches (AOD-071), "drop" (matches Altium), or "saved" |
bom_rules | Altium IPC-2581 rules | BOM grouping, $Name field templates, characteristics, bom toggle, and populate flag (partial dicts accepted) |
panel | Altium panel rules | Panel copy inclusion and copy designator format (partial dicts accepted) |
document_layers | all non-empty | Non-electrical DOCUMENT layers to include (KEEPOUT, MECHANICAL<n>, DRILLDRAWING<n>): omit for all non-empty document layers, [] for none, or pass an explicit list of keys |
virtual_layers | () | Additional virtual layers written as <Layer> + <LayerFeature> outside <StackupGroup>: "CUTOUTS" (DOCUMENT, side ALL) and sixteen sided layers (PIN1_*/POLARITY_*, DIODES_*, CAPACITORS_*, INDUCTORS_*, RESISTORS_*, ASSEMBLY_OUTLINES_*, ASSEMBLY_DESIGNATORS_*, PAD_LABELS_* as ASSEMBLY, side TOP/BOTTOM) |
virtual_options | None | Optional VirtualLayerOptions configuring virtual layers (see Virtual Fab Layers) |
Customizing IPC-2581 BOM, Document Layers, And Virtual Layers
bom_rules accepts a FabBomRules instance (from altium_monkey.fab_view_contracts.generated) or a partial dict (omitted fields keep Altium's defaults). Any $Name template resolves component properties ($DesignItemId, $LibraryName, $Footprint, $Package, $FootprintDescription, $Description, $Comment) or case-insensitive component parameters. When the board has no components or bom=False, <Bom> and <Avl> are omitted to keep the document strictly schema-valid. Virtual layers passed in virtual_layers are emitted outside <StackupGroup> whenever non-empty:
from altium_monkey.fab import VirtualLayerOptions
# Emit custom OEM/MPN fields, selected document layers, and virtual assembly layers
ipc = fab.to_ipc2581(
bom_rules={
"design_number": "$MPN",
"part_number": "$InternalPN",
"characteristics": ["MPN", "Manufacturer"],
"populate": True,
},
document_layers=["KEEPOUT", "MECHANICAL1"],
virtual_layers=("CUTOUTS", "PIN1_TOP", "DIODES_TOP", "ASSEMBLY_OUTLINES_TOP"),
virtual_options=VirtualLayerOptions(),
)
# Omit <Bom>/<Avl> and all optional document layers
minimal_ipc = fab.to_ipc2581(bom_rules={"bom": False}, document_layers=[])PCB & Footprint SVG (to_svg, to_layer_svgs)
Draws either one composite board image (board.svg) or one aligned image per layer key (<KEY>.svg plus DRILLS.svg) in millimetres. Both methods accept any virtual layer key inside layers=(...) along with virtual_options=VirtualLayerOptions(...) (supporting monochrome and shaded + contrast-halo rendering). AltiumPcbFootprint exposes the same to_svg and to_layer_svgs methods (plus parameters via FootprintSvgOptions).
Key options (SvgOptions, plus keyword-only virtual_options):
| Option | Default | Meaning |
|---|---|---|
layers | all board keys | Ordered layer keys to draw/image ("PROFILE" for board outline, "DRILLS" for holes, plus any virtual layer key such as "DIODES_TOP", "PIN1_TOP"/"POLARITY_TOP", "CAPACITORS_TOP", "INDUCTORS_TOP", "RESISTORS_TOP", "CUTOUTS", "ASSEMBLY_OUTLINES_TOP", "ASSEMBLY_DESIGNATORS_TOP", "PAD_LABELS_TOP") |
layer_colours | {} | Override colours by layer key ("#rrggbb"); applies to monochrome layers and monochrome virtual layers |
scale | 1.0 | Display size per millimetre |
hidden_component_texts | "omit" | "omit" hides NAMEON/COMMENTON-hidden texts; "draw" draws them |
degenerate_strokes | "draw" | "draw" or "omit" |
mirror | False | Mirror left-to-right about the frame centre (bottom view) |
clip_to_outline | False | Clip each layer to the board profile less its cutouts |
clip_holes | False | Knock spanned drill holes out of each copper layer |
metadata | False | Emit data-kind, data-id, data-net, data-source on elements |
annotations | [] | Overlays drawn above layers: [{"kind": "pad_labels"}, {"kind": "origin_marker"}] |
virtual_options | None | Optional VirtualLayerOptions controlling virtual layer geometry, text font mode, and shaded vs. monochrome styling (see Virtual Fab Layers) |
See the SVG contract for coordinate conventions, layer ordering, and annotation markup.
Pick & Place (to_pnp) And PCB BOM (to_bom)
fab.to_pnp(units="mm", panel=...)writes Altium's Pick and Place CSV (Pick Place for <board>(<variant>).csv), varying parameters by designator, listing fitted parts (excluding no-BOM kinds), and including panel copies by default (AOD-070).fab.to_bom(bom_rules=..., panel=...)writes Altium's flat PcbDoc BOM CSV (Bill of Materials-<board>(<variant>).csv), varying parameters byUniqueId, sorted by Altium'sComment=Uporder.- Both CSV files are encoded in Windows-1252 (
file.encoding == "cp1252") to match Altium. Usefile.textto read decoded Pythonstrorfile.datafor exact Windows-1252 bytes.
Panels And Embedded Board Arrays
Fab and FabView compose Altium panel .PcbDoc files containing EmbeddedBoards6 arrays across Gerber, NC drill, IPC-2581B, PCB SVG, Pick & Place, and PCB BOM.
Child Board Resolution
For each embedded board array, FabView searches for the child .PcbDoc in two locations, in order:
- Beside the panel file (
panel_path.parent / stored_namefor stored Windows-absolute paths, orpanel_path.parent / relative_pathfor relative paths). - At the stored Windows-absolute
DOCUMENTPATHitself.
- Pathless in-memory panels: A panel loaded via
AltiumPcbDoc.from_bytes(data)with no filename hasfilepath=Noneand cannot resolve relative child paths. Load panel boards withfrom_file(...)(or passfilename=when loading from bytes). - Missing or cyclic children (AOD-040): Unlike Altium (which aborts and writes zero files),
FabViewreportsembedded_board_child_missingorembedded_board_cycleindiagnosticsand still emits the panel and all readable children.
Flattened Copies vs. StepRepeat
- Gerber, NC drill, SVG, Pick & Place, and PCB BOM use
copies="flatten", expanding one level of embedded board arrays (matching Altium's Gerber and NC drill; nested arrays two levels down emitembedded_board_nested_not_drawn, AOD-043).- Mirrored copies swap top/bottom copper, overlay, solder mask, paste, and paired mechanical layers (and reverse inner copper stack order).
TRANSMITLAYERSexcludes listed child V7 layers from the panel; the other fourTRANSMIT*flags (TRANSMITDRILLTABLE,TRANSMITBOARDSHAPE,TRANSMITDIMENSIONS,TRANSMITLAYERSTACKTABLE) are preserved in the record API but are not consumed byFabViewyet.- Gerber writes only the inner copper/plane films used by the panel and its children rather than Altium's empty unused inner films (AOD-062).
- Board-edge rout routes the panel cutouts, panel outline, and each copy's outer outline (child cutouts are not routed and emit
embedded_board_copy_cutouts_not_routed).
- IPC-2581B uses
copies="steps"and emitsStep/StepRepeattrees with spec-compliant copy counts (nx/nyinclude the first copy, AOD-041) and Gerber-aligned copy placements (AOD-020). Inspect step trees in Python withview.repeats(),view.child(step), andfab_step_model_bytes(view, step)/fab_model_bytes(view, step, model)for child STEP payloads.
Panel Assembly Options (panel={...})
to_pnp, to_bom, and to_ipc2581 accept a panel option (PanelOptions / FabPanelOptions from altium_monkey.fab) controlling copy inclusion and copy designator formatting. You can pass a FabPanelOptions instance or a partial dict — omitted keys take Altium's defaults (copies_in_pnp=True, copies_in_bom=False, copy_designators="same"):
pnp = fab.to_pnp(panel={"copy_designators": "$Component_$CopyIndex"})
bom = fab.to_bom(panel={"copies_in_bom": True})Supported copy_designators template tokens are $Component, $ComponentPrefix, $ComponentIndex, $CopyIndex, $CopyRow, $CopyColumn, $CopyAlpha, $ArrayIndex, and $BoardName. Copy components remain fitted=True (panel project variants do not apply to child board copies).
For inspecting and authoring EmbeddedBoards6 records directly, see Embedded Board Arrays in PcbDoc and the pcbdoc_embedded_board_panel example.
Custom Lowerings With fab.view()
When building your own exporter, DRC check, or viewer, request a FabView directly:
from altium_monkey import AltiumPcbDoc, FabView
board = AltiumPcbDoc.from_file("board.PcbDoc")
view = board.fab().view(geometry="saved", copies="flatten", variant="applied")
for row in view.layers():
items = view.layer(row.key)
lands = items.lands or ()
strokes = items.strokes or ()
areas = items.areas or ()
print(f"{row.key:16s} ({row.role}): {len(lands)} lands, {len(strokes)} strokes, {len(areas)} areas")
# Round-trip the view as validated altium_monkey.fab_view.a0 JSON
raw_json = view.to_json()
reloaded = FabView.from_json(raw_json)
# Or read a saved dump from disk
# reloaded = FabView.from_file("fab_view.json")View Switches & Output Usage Table
Each to_* method selects the switches required by its target format. Pass the same switches to fab.view(...) when building a custom lowering:
| Output | geometry | copies | variant / variations | Why |
|---|---|---|---|---|
| Gerber | "plotted" | "flatten" | "fabrication" / "unique_id" | Gerber regions must be simple; strokes use round apertures; Altium flattens one panel level (AOD-043) |
| NC Drill | "plotted" | "flatten" | "fabrication" / "unique_id" | Shares the Gerber draw; drills every panel copy |
| SVG | "plotted" | "flatten" | "fabrication" / "unique_id" | Simple regions guarantee SVG even-odd fill matches non-zero fill |
| IPC-2581 | "saved" | "steps" | "fabrication" / "unique_id" | Native contours with cutouts and stroke caps; nested StepRepeat |
| Pick & Place | "saved" | "flatten" | "applied" / "designator" | Variant always applies; parameter variations match by designator |
| PCB BOM | "saved" | "flatten" | "applied" / "unique_id" | Variant always applies; parameter variations match by UniqueId |
fab.view() default | "saved" | "flatten" | "applied" / "unique_id" | Caller-configurable via ViewOptions |
Layer Keys
view.layers() returns the board's layer matrix in Altium's IPC-2581 order. Pass any key to view.layer(key) (a key the board lacks returns empty FabLayerItems with no error):
| Key | Role | Notes |
|---|---|---|
TOP, MID<n>, BOTTOM | conductor | Real copper layers |
PLANE<n> | conductor (negative) | Internal plane negative film (areas + clears) |
PLANE<n>COPPER | plane_copper | Virtual positive plane copper derived once from the film |
TOPSOLDER, BOTTOMSOLDER, TOPPASTE, BOTTOMPASTE | solder_mask, paste | Main mask and paste films |
TOPSOLDER<n>, TOPPASTE<n>, … | solder_mask, paste | Numbered rigid-flex substack films |
TOPSOLDERCOVER, BOTTOMSOLDERCOVER | mask_cover | Virtual mask cover film (board dark, openings and open bores clear) |
TOPOVERLAY, BOTTOMOVERLAY | silkscreen | Silkscreen overlay layers |
MECHANICAL<n>, KEEPOUT | mechanical, keepout | Mechanical layers (including coverlay outlines 64530+) and Keep-Out |
DIELECTRIC<n> | dielectric | Virtual stackup dielectric rows (no drawn items) |
TOPPADMASTER, BOTTOMPADMASTER | pad_master | Virtual pad-master layers |
DRILLGUIDE<n>, DRILLDRAWING<n> | drill_guide, drill_drawing | Virtual per-drill-pair guide and drawing films |
PROFILE | profile | Virtual board outline film |
ROUT | rout | Virtual board-edge rout toolpaths |
CUTOUTS, PIN1_*, DIODES_*, CAPACITORS_*, INDUCTORS_*, RESISTORS_*, ASSEMBLY_OUTLINES_*, ASSEMBLY_DESIGNATORS_*, PAD_LABELS_* | virtual | On-demand board-derived virtual layers (all 17 canonical keys, see Virtual Fab Layers); also queryable via view.layer(key) with defaults or view.virtual_layer(key, options) |
Core Query Methods On FabView
| Query | Returns | Notes |
|---|---|---|
context() | FabViewContext | Resolved switches, options, project, BOM/panel rules |
board() | FabBoard | Step ID ("s0"), file identity + SHA-256, user origin (nm) |
layers() / layer(key) | tuple[FabLayer, ...] / FabLayerItems | Layer matrix and per-key lands, strokes, areas, clears, texts, routs (computes on-demand virtual keys with defaults) |
virtual_layer(key, options=None) | VirtualLayerResult | Compute a virtual layer with explicit VirtualLayerOptions; call .to_fab_layer_items() for canonical FabLayerItems |
holes() / counterholes() / drill_pairs() | tuples | Drilled holes, counterbores/countersinks, drill-pair spans |
profile() | FabProfile | None | Board outer ring and cutouts (each with optional record source) |
components() / placements() / packages() | tuples | Full component+package view, or fast record-only placements() without package synthesis |
owners() / padstacks() | tuples | Per-pad/via owners and deduplicated padstack definitions |
nets() | tuple[FabNet, ...] | Active nets, net classes, net-tie groups, optional merged names |
stackup() / regions() / appearance() | stackup / regions / colours | Physical stackup + service substacks, board regions/cavities/bends |
bodies() / models() / model_bytes(id) | 3D bodies & STEP bytes | Decompressed STEP payloads (see also fab_step_model_bytes, fab_model_bytes) |
repeats() / child(step) | panel repeats & child views | Embedded board array repeats and per-child FabView |
bom() / fonts() | BOM lines / FabFontReport | Grouped BOM lines and TrueType font resolution report |
diagnostics(scope) | tuple[FabDiagnostic, ...] | Pass any layer key or board scope ("holes", "profile", "board", "fonts", "components", "packages", "bodies", "bom") |
to_json(layers=None) / from_json(data) / from_file(path) | bytes / FabView | Validated altium_monkey.fab_view.a0 dump serialization and reload |
Practical Notes For Python Users
- Absent fields use
msgspec.UNSET, notNone: GeneratedFabViewstructs omit absent fields withmsgspec.UNSET.bool(UNSET)isFalse, soitems.lands or ()works as expected, butUNSET is not NoneisTrue. Check optional scalar fields withisinstance(land.net, str)(orland.net is not UNSET) rather thanis not None. - Use
placements()when you don't need packages:view.placements()returns the sameFabComponentrows asview.components()without computing the package table, which is faster on large boards when you only need designators, coordinates, pins, and parameters. - Units in
FabView: All geometry coordinates and dimensions inFabViewanswers are whole nanometres (int), +Y up. - Matching Altium vs. fabrication defaults: Defaults fix confirmed Altium bugs and spec violations (such as zero-length strokes
AOD-001, Gerber X2 / 1 nm gridAOD-004, missing pad mask shapesAOD-008, back-drill start landsAOD-014, negative IPC-2581 standoffsAOD-021, keepout textsAOD-042, and edge-touching cutoutsAOD-071). See the full Altium output differences register for all 76 documented entries and comparison options.
Runnable Examples
fab_release_package: complete variant-aware Gerber X2/X1 (with layer selection, dual-key customextensions, virtual layers, andprofile_cutouts), NC Drill, IPC-2581B (withdocument_layersandvirtual_layers), Pick & Place, BOM, and clipped top/bottom + virtual overlay preview SVGsfab_virtual_layers_to_mechanical: computeCUTOUTS,PIN1_TOP,DIODES_TOP,ASSEMBLY_OUTLINES_TOP, andASSEMBLY_DESIGNATORS_TOPwith explicitVirtualLayerOptionsand bake their geometry onto cleared Altium mechanical layers (Mechanical 11–15)fab_view_query_and_fonts: directFabViewqueries,view.virtual_layer(...)inspection,altiumvs.embedded_firstfont policies, JSON round-trip, and annotated/virtual SVGspcbdoc_embedded_board_panel: 1x4 HydroScope tab-rout panel with NPTH tooling holes, IPC-7351 circular fiducials, and 4-side NPTH mouse bitespcbdoc_vgroove_panel: 0-gap 1x4 HydroScope V-groove (V-score) panel with full-width V-score linespcbdoc_barcodes_1d_and_2d: authoring and flattening Code 39, Code 128, QR Code, and Data Matrix PCB barcodes