On This Page (15)
- Supported Virtual Layer Keys
- Quick Start Across Outputs
- VirtualLayerOptions Reference
- Top-Level VirtualLayerOptions & Vector Text Fonts
- Component Visibility Policy (ComponentVisibilityPolicy) And Strict Orthogonality
- Board Cutouts (CutoutLayerOptions & profile_cutouts)
- Pin 1 & Polarity Markers (PIN1_TOP / PIN1_BOTTOM, Aliases POLARITY_TOP / POLARITY_BOTTOM)
- Diode Orientation (DIODES_TOP / DIODES_BOTTOM)
- Passive Orientation & Symbol Layers (CAPACITORS_*, INDUCTORS_*, RESISTORS_*)
- Assembly Outlines & Designators (ASSEMBLY_OUTLINES_* & ASSEMBLY_DESIGNATORS_*)
- Pad Designator Labels (PAD_LABELS_TOP / PAD_LABELS_BOTTOM, .GPLT / .GPLB)
- STEP HLR Caching, Progress Callbacks & VirtualItemStyle
- Baking Virtual Layers To Mechanical Layers
- Inspecting VirtualLayerResult Directly
- Runnable Examples
Virtual Fab Layers
Board-derived virtual layers synthesize fabrication and assembly review artwork on demand from a normalized FabView — board cutouts, Pin 1 and polarity markers, diode polarity glyphs, passive component symbols (capacitors, inductors, resistors), 3D-projected assembly outlines, fitted assembly designators, and fitted pad designator labels — without mutating the source .PcbDoc (or .PcbLib footprint view).
Because every virtual layer is computed once from FabView answers (profile(), placements(), holes(), bodies(), models(), and outer copper layers), the exact same geometry is shared consistently across:
- Gerber X2/X1 (
fab.to_gerbers(virtual_layers=..., virtual_options=...)) - IPC-2581B (
fab.to_ipc2581(virtual_layers=..., virtual_options=...)) - PCB & Footprint SVG (
fab.to_svg(layers=(..., "DIODES_TOP", "PAD_LABELS_TOP"), virtual_options=...)andfab.to_layer_svgs(...)) - CLI workflows (
acr fab,acr vdoc,acr pcb-svg, andacr dr) - Direct Python inspection & mechanical-layer baking (
view.virtual_layer(key, options)->VirtualLayerResult,bake_virtual_layers_to_pcbdoc,bake_virtual_layers_to_pcblib)
Composite SVG of the 34-component virtual_fab_layers showcase board rendered with the default pcb-svg color palette, opacities, and draw order (BOARD_OUTLINE, CUTOUTS, TOP copper, plated/NPTH DRILLS, ASSEMBLY_OUTLINES_TOP 3D STEP HLR, ASSEMBLY_DESIGNATORS_TOP, PIN1_TOP, DIODES_TOP, CAPACITORS_TOP, INDUCTORS_TOP, and RESISTORS_TOP) using unclipped all-geometry framing.
Supported Virtual Layer Keys
All 17 canonical virtual layer keys — plus the convenience aliases POLARITY_TOP / POLARITY_BOTTOM (and PIN_1_TOP / PIN_1_BOTTOM) for PIN1_TOP / PIN1_BOTTOM — are case-insensitive when passed to virtual_layers=..., layers=..., or view.virtual_layer(...):
| Virtual Layer Key | Display Name | Role | Side | Gerber Ext | SVG Colour |
|---|---|---|---|---|---|
CUTOUTS | Board Cutouts | cutouts | board | .GCU | #D71920 |
PIN1_TOP | Top Pin 1 Markers | pin1 | top | .GP1T | #1479CC |
PIN1_BOTTOM | Bottom Pin 1 Markers | pin1 | bottom | .GP1B | #1479CC |
DIODES_TOP | Top Diode Orientation | diodes | top | .GDT | #E67E22 |
DIODES_BOTTOM | Bottom Diode Orientation | diodes | bottom | .GDB | #E67E22 |
CAPACITORS_TOP | Top Capacitors | capacitors | top | .GCT | #0D9488 |
CAPACITORS_BOTTOM | Bottom Capacitors | capacitors | bottom | .GCB | #0D9488 |
INDUCTORS_TOP | Top Inductors | inductors | top | .GLT | #7C3AED |
INDUCTORS_BOTTOM | Bottom Inductors | inductors | bottom | .GLB | #7C3AED |
RESISTORS_TOP | Top Resistors | resistors | top | .GRT | #059669 |
RESISTORS_BOTTOM | Bottom Resistors | resistors | bottom | .GRB | #059669 |
ASSEMBLY_OUTLINES_TOP | Top Component Outlines | assembly_drawing | top | .GAT | #1F2937 |
ASSEMBLY_OUTLINES_BOTTOM | Bottom Component Outlines | assembly_drawing | bottom | .GAB | #1F2937 |
ASSEMBLY_DESIGNATORS_TOP | Top Component Designators | assembly_drawing | top | .GADT | #111827 |
ASSEMBLY_DESIGNATORS_BOTTOM | Bottom Component Designators | assembly_drawing | bottom | .GADB | #111827 |
PAD_LABELS_TOP | Top Pad Labels | pad_labels | top | .GPLT | #0284C7 |
PAD_LABELS_BOTTOM | Bottom Pad Labels | pad_labels | bottom | .GPLB | #0284C7 |
Every virtual layer emits Gerber X2 .FileFunction=OtherDrawing,<Display Name> and IPC-2581 ASSEMBLY / TOP|BOTTOM (DOCUMENT / ALL for CUTOUTS).
Key cross-format behaviors:
- Gerber: Every virtual layer lowers as pure monochrome positive Gerber geometry (
.FilePolarity=Positive). Custom extensions can be overridden into_gerbers(extensions=...)by either canonical key (e.g."CUTOUTS": "GCO","PAD_LABELS_TOP": "GPLT") or default extension (e.g."GCU": "GCO"). Cutout hatching and"CUTOUT"labels can also be drawn directly onto the.GMboard profile film withprofile_cutouts=True(orCutoutLayerOptions(on_profile=True)). - IPC-2581B: Non-empty virtual layers are emitted as
<Layer>and<LayerFeature>records and are excluded from<StackupGroup>so the physical stackup remains unchanged.CUTOUTSuseslayerFunction="DOCUMENT",side="ALL"; the sixteen sided layers uselayerFunction="ASSEMBLY",side="TOP"or"BOTTOM". Empty virtual layers are omitted. - SVG: Virtual layers support two paint modes:
- Monochrome: All primitives paint with a single colour (from
layer_colours[key]or the layer's default colour). Used by assembly outlines, assembly designators, and any symbol layer withcolor_mode="monochrome". - Shaded: Uses per-item
VirtualItemStyle(fill, darkerstroke, white contrasthalo_color/halo_width_nmdrawn underneath, optionaldash_array_nm, and optionalopacitysuch as0.5for Pin 1 diodeA/Klabels) so polarity markers, LED colours, passive symbols, Pin 1 dots, and cutout callouts stay legible over busy copper and silkscreen layers. Gerber lowering ignoresstylesand always emits pure monochrome vector geometry.
- Monochrome: All primitives paint with a single colour (from
Quick Start Across Outputs
from altium_monkey import AltiumPcbDoc
from altium_monkey.fab import (
AssemblyDesignatorLayerOptions,
AssemblyOutlineLayerOptions,
CapacitorLayerOptions,
ComponentVisibilityPolicy,
CutoutLayerOptions,
DiodeLayerOptions,
InductorLayerOptions,
Pin1LayerOptions,
ResistorLayerOptions,
VirtualLayerOptions,
)
board = AltiumPcbDoc.from_file("board.PcbDoc")
fab = board.fab()
virtual_opts = VirtualLayerOptions(
font_mode="stroke",
stroke_font="sans_serif",
visibility=ComponentVisibilityPolicy(
exclude_kinds=("graphical", "net_tie"),
),
cutouts=CutoutLayerOptions(scope="interior", hatch=True, hatch_pitch_mm=1.0),
pin1=Pin1LayerOptions(
style="dot",
knockout=False,
exclude_designator_prefixes=("R", "C", "L"),
diode_ak_labels=True,
cap_polarity_labels=True,
inductor_polarity_markers=True,
),
diodes=DiodeLayerOptions(color_mode="shaded"),
capacitors=CapacitorLayerOptions(visibility_mode="polarized_only", color_mode="shaded"),
inductors=InductorLayerOptions(visibility_mode="polarized_only", color_mode="shaded"),
resistors=ResistorLayerOptions(style="zigzag", color_mode="shaded"),
assembly_outlines=AssemblyOutlineLayerOptions(detail="simple"),
assembly_designators=AssemblyDesignatorLayerOptions(
min_font_size_mm=0.08,
max_font_size_mm=2.40,
fill_ratio=0.78,
),
)
# 1. Gerber X2 with virtual layers + hatched cutout callouts on .GM
gerbers = fab.to_gerbers(
virtual_layers=(
"CUTOUTS",
"POLARITY_TOP", # alias for PIN1_TOP
"DIODES_TOP",
"CAPACITORS_TOP",
"INDUCTORS_TOP",
"RESISTORS_TOP",
"ASSEMBLY_OUTLINES_TOP",
"ASSEMBLY_DESIGNATORS_TOP",
),
profile_cutouts=True,
virtual_options=virtual_opts,
)
# 2. IPC-2581B with virtual DOCUMENT / ASSEMBLY layers (excluded from <StackupGroup>)
ipc = fab.to_ipc2581(
virtual_layers=("CUTOUTS", "PIN1_TOP", "DIODES_TOP", "CAPACITORS_TOP", "ASSEMBLY_OUTLINES_TOP"),
virtual_options=virtual_opts,
)
# 3. Composite SVG with shaded virtual overlays
svg = fab.to_svg(
layers=(
"PROFILE",
"TOP",
"TOPSOLDER",
"ASSEMBLY_OUTLINES_TOP",
"ASSEMBLY_DESIGNATORS_TOP",
"PIN1_TOP",
"DIODES_TOP",
"CAPACITORS_TOP",
"INDUCTORS_TOP",
"RESISTORS_TOP",
"CUTOUTS",
),
virtual_options=virtual_opts,
)VirtualLayerOptions Reference
All virtual-layer option, visibility, style, and STEP HLR cache types are exported directly from altium_monkey.fab (and also from altium_monkey.fab.virtual):
from altium_monkey.fab import (
AssemblyDesignatorLayerOptions,
AssemblyHlrCache,
AssemblyOutlineLayerOptions,
AssemblyOutlineOverride,
CapacitorLayerOptions,
CapacitorOverride,
ComponentVisibilityOverride,
ComponentVisibilityPolicy,
CutoutLayerOptions,
DiodeLayerOptions,
DiodeOverride,
GeometerProgressCallback,
HlrProjectedArc,
HlrProjectedGeometry,
InductorLayerOptions,
InductorOverride,
MechanicalLayerCollision,
MechanicalLayerTarget,
PadLabelLayerOptions,
Pin1LayerOptions,
Pin1Override,
ResistorLayerOptions,
ResistorOverride,
VirtualItemStyle,
VirtualLayerOptions,
VirtualLayerResult,
BakeLayerReport,
BakeVirtualLayersOptions,
BakeVirtualLayersReport,
bake_virtual_layers_to_pcbdoc,
bake_virtual_layers_to_pcblib,
detect_mechanical_layer_collisions,
)Top-Level VirtualLayerOptions & Vector Text Fonts
| Field | Type | Default | Meaning |
|---|---|---|---|
font_mode | "stroke" | "truetype" | "stroke" | Vector text renderer shared by cutout labels, Pin 1 / polarity pad labels, assembly designators, and pad labels. "stroke" uses a built-in Altium vector stroke font (stroke_font); "truetype" outlines TrueType glyphs as filled polygons (falling back to "stroke" if the font face is unavailable). |
stroke_font | "sans_serif" | "serif" | "default" | "sans_serif" | Built-in Altium vector stroke font used when font_mode="stroke". |
font_family | str | "Arial" | TrueType font family used when font_mode="truetype". |
font_bold | bool | True | Bold weight flag when font_mode="truetype". |
dnp_mode | "omit" | "crossout" | "omit" | How assembly-variant Not Fitted (DNP) components render across component-scoped virtual layers. "omit" (default) hides DNP parts from all 8 component-scoped families. "crossout" keeps DNP parts on ASSEMBLY_OUTLINES_* as a dimmed dashed outline with a muted-red diagonal X (kind="assembly_dnp_crossout") and a dimmed label on ASSEMBLY_DESIGNATORS_*, while still omitting them from PIN1_*, DIODES_*, CAPACITORS_*, INDUCTORS_*, RESISTORS_*, and PAD_LABELS_*. Bare-board copper, solder mask, paste, and silkscreen remain invariant on Altium's fabrication view. |
visibility | ComponentVisibilityPolicy | (defaults) | Unified component inclusion/exclusion rules across all 8 component-scoped families (assembly_outlines, assembly_designators, pin1, pad_labels, diodes, capacitors, inductors, resistors). |
cutouts | CutoutLayerOptions | (defaults) | Scope, hatching, label text, and .GM profile overlay toggle for board cutouts (merging overlapping cutouts cleanly). |
pin1 | Pin1LayerOptions | (defaults) | Pin 1 and polarity marker style (dot/square/pad/pin_label), negative knockout, exclude_two_pin_prefixes=("X", "Y"), diode A/K, capacitor +/-, inductor polarity dots, visibility_mode, and per-component overrides. |
diodes | DiodeLayerOptions | (defaults) | Diode polarity parameters, heuristics, visibility_mode, SVG shading mode, and per-component overrides. |
capacitors | CapacitorLayerOptions | (defaults) | Capacitor polarity parameters, visibility_mode ("polarized_only" default, legacy include_non_polarized bridge), + sign, SVG shading mode, and per-component overrides. |
inductors | InductorLayerOptions | (defaults) | Inductor polarity parameters (INDUCTOR_POLARITY_PAD with PIN1_PAD fallback), visibility_mode ("polarized_only" default, legacy include_non_polarized bridge), SVG shading mode, and per-component overrides. |
resistors | ResistorLayerOptions | (defaults) | Resistor symbol style ("zigzag" or "box"), parameters, visibility_mode, SVG shading mode, and per-component overrides. |
assembly_outlines | AssemblyOutlineLayerOptions | (defaults) | 3D/body outline detail level ("simple", "detail", or "bounding_box"), stroke widths, visibility_mode, and per-component overrides. |
assembly_designators | AssemblyDesignatorLayerOptions | (defaults) | Fitted assembly designator sizing (min_font_size_mm, max_font_size_mm, fill_ratio), visibility_mode, and per-component overrides. |
pad_labels | PadLabelLayerOptions | (defaults) | Fitted pad designator labels (PAD_LABELS_TOP / PAD_LABELS_BOTTOM) with stroke/TrueType font overrides, geometric knockout, mechanical/through-hole pad filters, visibility_mode, per-component overrides, and .PcbDoc + .PcbLib footprint_view support. |
hlr_cache | AssemblyHlrCache | None | None | Optional persistent cache hook (load/store) for Geometer STEP HLR projections. |
progress | Callable[[str], None] | None | None | Optional callback receiving Geometer STEP projection progress messages. |
font_mode="stroke", stroke_font="default" — Altium classic vector stroke font.
font_mode="stroke", stroke_font="sans_serif" (default) — clean technical sans-serif vector strokes.
font_mode="stroke", stroke_font="serif" — Altium serif vector stroke font.
font_mode="truetype", font_family="Arial" — filled TrueType glyph outline polygons.
Component Visibility Policy (ComponentVisibilityPolicy) And Strict Orthogonality
Every component-scoped virtual layer family — all 8 families (assembly_outlines, assembly_designators, pin1, pad_labels, diodes, capacitors, inductors, and resistors) — separates what a part is (Semantics) from whether to draw its symbol (Visibility) using one uniform, strictly one-way pipeline:
- Semantics (what it is & how it draws) comes from Altium semantic parameters (
CATHODE_PAD,DIODE_TYPE,POSITIVE_PAD,CAPACITOR_TYPE,INDUCTOR_POLARITY_PAD,PIN1_PAD,RESISTOR_STYLE,*_COLOR) and semantic config overrides. HidingDIODES_*,CAPACITORS_*, orINDUCTORS_*never stripsA/K,+/-, or inductor polarity dots fromPIN1_*. - Visibility (whether to draw on a family's layer) is governed uniformly by
ComponentVisibilityPolicy+ per-familyvisibility_mode. Setting a semantic-only config override (such asstyle="box"orcolor="red"withenabled=None) never forces visibility on. Visibility parameters never invent fake family membership on unrelated parts (for example,RESISTOR_SYMBOL="true"on an IC does not draw a resistor symbol). - One-way config flow: CLI tools (
acr fab,acr vdoc,acr pcb-svg,acr toon,acr dr) read Altium parameters at runtime and never auto-mutate.jsoncconfig files. Config files own project policy and overrides; Altium parameters are read-only inputs.
| Field | Type | Default | Meaning |
|---|---|---|---|
exclude_kinds | tuple[str, ...] | ("graphical", "net_tie") | Component kinds excluded by default. Keeps "standard_no_bom" (bare test points, fiducials, wire pads) visible unless explicitly added. |
exclude_designator_prefixes | tuple[str, ...] | () | Alphabetic designator prefixes excluded across all 8 visibility-governed families (case-insensitive). |
outline_parameter | str | "ASSEMBLY_OUTLINE" | Altium component/footprint parameter controlling ASSEMBLY_OUTLINES_* (accepts boolean tokens or "simple" / "detail" / "bounding_box"). |
designator_parameter | str | "ASSEMBLY_DESIGNATOR" | Altium component/footprint parameter controlling ASSEMBLY_DESIGNATORS_*. |
pin1_parameter | str | "PIN1_MARKER" | Altium component/footprint parameter controlling PIN1_*. |
pad_labels_parameter | str | "PAD_LABELS" | Altium component/footprint parameter controlling PAD_LABELS_*. |
diode_parameter | str | "DIODE_SYMBOL" | Altium component/footprint boolean parameter controlling DIODES_*. |
capacitor_parameter | str | "CAPACITOR_SYMBOL" | Altium component/footprint boolean parameter controlling CAPACITORS_*. |
inductor_parameter | str | "INDUCTOR_SYMBOL" | Altium component/footprint boolean parameter controlling INDUCTORS_*. |
resistor_parameter | str | "RESISTOR_SYMBOL" | Altium component/footprint boolean parameter controlling RESISTORS_*. |
overrides | Mapping[str, ComponentVisibilityOverride] | {} | Shared per-component visibility matrix keyed by designator (assembly_outline, assembly_designator, pin1, pad_labels, diodes, capacitors, inductors, resistors each bool | None, matched case-insensitively). |
excluded_designators | frozenset[str] | frozenset() | Variant/DNP excluded designators suppressed unconditionally at Gate 1. |
Uniform resolution precedence (highest → lowest) across all 8 families:
- Gate 0 — Layer active: Layer enabled for the current command (
fab.jsonc,vdoc.jsonclayers, orpcb-svgviews[].layers). - Gate 1 — Population / Fitted (always wins): Unfitted / DNP components (from the active
.PrjPcbvariant,not component.fitted, orexcluded_designators) → ALWAYS HIDE on all 8 component-scoped families whendnp_mode="omit"(default), beating P1–P5. Whendnp_mode="crossout", DNP components appear onASSEMBLY_OUTLINES_*(dimmed dashed outline + red diagonalX) andASSEMBLY_DESIGNATORS_*(dimmed designator) while remaining hidden onPIN1_*,DIODES_*,CAPACITORS_*,INDUCTORS_*,RESISTORS_*, andPAD_LABELS_*. Bare-board fabrication layers (copper, solder mask, silkscreen) remain unchanged across assembly variants, matching Altium. - P1 — Family config override:
virtual_layers.<family>.overrides.<REF>.enabled(true/false; omittingenabledis semantic-only and falls through). - P2 — Shared visibility matrix override:
virtual_layers.visibility.overrides.<REF>.<family>(true/false). - P3 — Dedicated Altium boolean parameter:
ASSEMBLY_OUTLINE,ASSEMBLY_DESIGNATOR,PIN1_MARKER,PAD_LABELS,DIODE_SYMBOL,CAPACITOR_SYMBOL,INDUCTOR_SYMBOL, orRESISTOR_SYMBOL. Recognized true tokens:1,true,yes,on,show,include,enable,enabled. Recognized false tokens:0,false,no,off,none,hide,exclude,disable,disabled. A recognized parameter bypasses P4 exclusions and P5visibility_modeso any individual component can opt in (e.g.,CAPACITOR_SYMBOL="true"on a ceramic cap under"polarized_only"or"explicit") or opt out (e.g.,DIODE_SYMBOL="false"on one LED without affectingPIN1_TOP). - P4 — Global hard exclusions:
exclude_kinds(default["graphical", "net_tie"]) andexclude_designator_prefixes. - P5 — Family
visibility_modepolicy:- Polarity-capable families (
capacitors,inductors):"polarized_only"(default — draws polarized parts only),"all"(draws polarized and non-polarized parts), or"explicit"(draws only P1/P2/P3 opt-ins). Legacyinclude_non_polarized: true/falseremains accepted as a bridge to"all"/"polarized_only". - All other 6 families (
assembly_outlines,assembly_designators,pin1,pad_labels,diodes,resistors):"all"(default) or"explicit"(draws only P1/P2/P3 opt-ins).
- Polarity-capable families (
Unified "virtual_layers" JSONC sub-struct across all CLI tools:
fab.jsonc, vdoc.jsonc, pcb.svg.config (pcb.svg.config.a1), acr toon, acr dr, and MCO pcbdoc.bake_virtual_layers / pcblib.bake_virtual_layers all share the exact same "virtual_layers" schema. When a sibling fab.jsonc sits beside a board or project, acr vdoc, acr pcb-svg, acr toon, and acr dr automatically inherit its "virtual_layers" rules read-only (logging • Virtual opts .../fab.jsonc) while keeping each tool's own layer selection intact (Gerber-only *.enabled: false toggles in fab.jsonc never silence pcb-svg views). Any "virtual_layers" block authored in vdoc.jsonc or pcb.svg.config cleanly overrides the inherited fab.jsonc defaults.
End-To-End Flow Example (Altium Parameter → fab.jsonc → vdoc.jsonc / pcb.svg.config)
Suppose a board sets Altium component parameters directly in schematic/PCB:
R1:RESISTOR_SYMBOL = "true",RESISTOR_STYLE = "box"C3(ceramic MLCC):CAPACITOR_SYMBOL = "true"D2(status LED):DIODE_SYMBOL = "false"(still keepsA/KonPIN1_TOP!)
Define the project's shared virtual-layer rules once in fab.jsonc:
{
"schema": "fab_config.a0",
"virtual_layers": {
"visibility": {
"exclude_kinds": ["graphical", "net_tie"],
"overrides": {
"J7": { "assembly_outline": false, "assembly_designator": false }
}
},
"resistors": {
// Only draw resistors explicitly opted in via RESISTOR_SYMBOL="true" (like R1) or overrides
"visibility_mode": "explicit",
"overrides": {
// Semantic-only override (enabled omitted): changes style without forcing visibility on
"R5": { "style": "box" }
}
},
"capacitors": {
// Polarized caps auto-draw; ceramic C3 also draws because of CAPACITOR_SYMBOL="true"
"visibility_mode": "polarized_only"
},
"pad_labels": {
"knockout": false,
"min_height_mm": 0.06,
"max_height_mm": 2.0
}
}
}Then acr vdoc (vdoc.jsonc) and acr pcb-svg (pcb.svg.config) inherit all of those rules automatically from the sibling fab.jsonc, and only need local overrides where a specific workflow differs — for example, turning on negative knockout pad labels solely in vdoc.jsonc:
{
"schema": "vdoc_config.a0",
"layers": {
"PIN1_TOP": "MECHANICAL36",
"DIODES_TOP": "MECHANICAL38",
"CAPACITORS_TOP": "MECHANICAL46",
"RESISTORS_TOP": "MECHANICAL50",
"PAD_LABELS_TOP": "MECHANICAL44"
},
// Inherits visibility, resistors, and capacitors from sibling fab.jsonc;
// only overrides pad_labels.knockout locally:
"virtual_layers": {
"pad_labels": { "knockout": true }
}
}Board Cutouts (CutoutLayerOptions & profile_cutouts)
Renders board cutouts with exact arc-preserving outlines, automatic unioning of overlapping or touching cutout regions (so stacked or adjacent Altium cutout primitives never produce doubled borders, cross-hatched overlaps, or duplicate labels), clipped parallel vector hatch lines, and an automatically fitted "CUTOUT" label (with a cleared hatch window around the text; supports concave L/T/U/C cutouts, circular/obround cutouts, and diagonal slots).
All 7 source cutout primitives on virtual_fab_layers rendered with board outline (PROFILE), 45° clipped vector hatching, cleared "CUTOUT" label windows, and the two crossing slots automatically boolean-unioned into one seamless + cutout (6 unified interior cutout regions, with internal crossing segments removed).
| Field | Type | Default | Meaning |
|---|---|---|---|
scope | "interior" | "all" | "interior" | "interior" selects cutouts strictly inside the outer board boundary (ignoring edge notches); "all" includes every cutout in view.profile().cutouts. |
hatch | bool | True | Draw clipped parallel vector hatch lines across each selected cutout. |
hatch_angle_deg | float | 45.0 | Hatch line angle in degrees. |
hatch_pitch_mm | float | 1.0 | Spacing between adjacent hatch lines in millimetres (clamped to >= 0.1 mm). |
label | str | "CUTOUT" | Text fitted inside each cutout; set to "" to omit the label and hatch window. |
on_profile | bool | False | When True (or when to_gerbers(profile_cutouts=True)), draws hatched and labelled cutout callouts directly onto the .GM board profile film instead of solid-filling interior cutouts. Unselected cutouts remain stroked outlines. |
outline_width_mm | float | 0.10 | Stroke width in mm for cutout outlines. |
hatch_line_width_mm | float | 0.075 | Stroke width in mm for vector hatch lines. |
label_max_font_size_mm | float | 4.0 | Maximum fitted height in mm for cutout labels. |
label_fill_ratio | float | 0.72 | Fraction of available cutout span filled by the fitted label. |
label_rotation_min_gain | float | 0.25 | Minimum fractional height gain required before rotating the cutout label along the slot's principal axis. |
color_mode | "shaded" | "monochrome" | "shaded" | SVG rendering mode for cutout overlays. |
Pin 1 & Polarity Markers (PIN1_TOP / PIN1_BOTTOM, Aliases POLARITY_TOP / POLARITY_BOTTOM)
Marks Pin 1 and terminal polarity for fitted components on the top or bottom side, unifying IC/connector Pin 1 markers, diode A/K labels, polarized capacitor +/- labels, explicit POSITIVE_PAD/NEGATIVE_PAD callouts, and polarized inductor markers onto one clean layer.
PIN1_TOP (style="dot") on virtual_fab_layers: BGA U3 (A1), polarized inductor L2 (PIN1_PAD="2"), RGB LED D3 (POSITIVE_PAD="B+"), reverse-mount LED D6 (POSITIVE_PAD="1"), polarized capacitors C1/C2 (+/-), diodes D1/D2/D4/D5/D7–D11 (A/K), and non-polarized passives/fiducials/testpoints (C3, L1, R1, FID1–FID4, TP1–Tp3) cleanly skipped.
Four Pin 1 Styles & Pure Geometric knockout=True
Pin1LayerOptions.style (and per-component Pin1Override.style) supports four marker styles, plus an independent boolean knockout flag:
"dot"(default): Filled circle centered on the Pin 1 pad (or drilled hole for through-hole parts, full pad fill for BGA/LGA grid pads whengrid_pad_fill=True)."square": Filled square centered on the pad and rotated to match the pad's orientation."pad": Exact copper pad geometry filled in the marker paint."pin_label": Vector pin designator text (e.g.1,A1,2) fitted inside the pad bounds (falls back to"dot"on pads too tiny to hold legible text).knockout=True: Instead of drawing strokes on top of the pad, punches the glyph (A,K,+,-,A1,1, or customsymbol) out of the full pad polygon via boolean difference, producing a pureGeomPlanarRegionwith interior holes and preserved counter islands (such as the closed triangle insideAinA1orD8rotated 45°). Because knockout is pure planar geometry rather than an SVG mask, it lowers identically to Gerber X2/X1 regions, IPC-2581 contours, SVG<path fill-rule="evenodd">, and baked Altium mechanical regions!
style="dot" (default) — auto-scaled circular Pin 1 dot on U1, L2 (pin 2 via PIN1_PAD="2"), and full BGA grid pad fill on U3 (A1).
style="square" — pad-rotated square marker aligned with each Pin 1 pad.
style="pad" — fills the entire copper Pin 1 pad land shape.
style="pin_label" — fits the actual vector pin name (A1, 1, 2) directly inside the pad.
style="pin_label", knockout=True — close-up of BGA U3 pad A1 showing pure boolean subtraction preserving the triangular counter island inside A.
knockout=True on 45°-rotated diode D8 and LEDs — A/K glyphs punched cleanly out of rotated pad polygons.
| Field | Type | Default | Meaning |
|---|---|---|---|
style | "dot" | "square" | "pad" | "pin_label" | "dot" | Default Pin 1 marker geometry style. |
knockout | bool | False | Punch pin_label, A/K, +/-, and custom symbol glyphs out of the pad shape as pure negative GeomPlanarRegion geometry. |
grid_pad_fill | bool | True | Fill the full pad land for BGA/LGA grid pads (A1, B1, …) in "dot" and "square" modes. |
dot_diameter_mm | float | None | None | Optional explicit dot diameter in mm; None auto-scales to 0.70 × min_pad_dim (radius 0.35 × min_pad_dim) clamped to [min_dot_diameter_mm, max_dot_diameter_mm]. |
min_dot_diameter_mm | float | 0.40 | Lower clamp for auto-scaled Pin 1 dot diameter in mm. |
max_dot_diameter_mm | float | 0.90 | Upper clamp for auto-scaled Pin 1 dot diameter in mm. |
pad_parameter | str | "PIN1_PAD" | Altium component/footprint parameter naming the Pin 1 pad (e.g. L2 PIN1_PAD="2"), or "NONE"/"OFF"/"FALSE" to suppress. |
positive_parameter | str | "POSITIVE_PAD" | Altium parameter naming explicit + pad(s) (e.g. D3 POSITIVE_PAD="B+", D6 POSITIVE_PAD="1"). On multi-pin parts (> 2 pins), never infers - onto unrelated pins. |
negative_parameter | str | "NEGATIVE_PAD" | Altium parameter naming explicit - pad(s). |
exclude_designator_prefixes | tuple[str, ...] | ("R", "C", "L") | Prefixes skipped by generic Pin 1 auto-detection (bypassed by explicit POSITIVE_PAD/NEGATIVE_PAD/PIN1_PAD, polarized capacitors, polarized inductors, and P1–P3 opt-ins). |
exclude_two_pin_prefixes | tuple[str, ...] | ("X", "Y") | Prefixes skipped by generic Pin 1 auto-detection only when the component has exactly 2 copper pads — keeps non-polarized 2-pin crystals (X*, Y*) clean while still marking 4-pin active oscillators, 4-pad crystal packages, and explicit PIN1_PAD / P1–P3 opt-ins. |
diode_ak_labels | bool | True | Draw A/K inside anode and cathode pads for detected diodes. |
cap_polarity_labels | bool | True | Draw +/- inside positive and negative pads for detected polarized capacitors. |
inductor_polarity_markers | bool | True | Draw a Pin 1 marker on the winding-start pad of polarized inductors (INDUCTOR_POLARITY_PAD or PIN1_PAD). |
visibility_mode | "all" | "explicit" | "all" | "all" marks eligible components automatically; "explicit" draws only P1/P2/P3 opt-ins (overrides.<ref>.enabled=True, visibility.overrides.<ref>.pin1=True, or PIN1_MARKER="true"). |
color_mode | "shaded" | "monochrome" | "shaded" | SVG rendering mode for Pin 1 markers. |
overrides | Mapping[str, Pin1Override] | {} | Per-component Pin1Override(enabled=None, pad=None, style=None, knockout=None, symbol=None, positive_pad=None, negative_pad=None) overrides (case-insensitive designator lookup; enabled=None is semantic-only and falls through to P2–P5). |
Pin 1 / Polarity two-stage resolution order:
- Visibility gates (Gate 1 + P1–P5): Unfitted / DNP (
not component.fittedor inexcluded_designators) always hides; thenpin1.overrides[ref].enabled(P1),visibility.overrides[ref].pin1(P2),PIN1_MARKERparameter (P3), globalexclude_kinds/exclude_designator_prefixes(P4), andpin1.visibility_mode("all"vs"explicit", P5). Explicit P1–P3 opt-ins (True) also bypasspin1.exclude_designator_prefixesandpin1.exclude_two_pin_prefixesin step 6. - Explicit
POSITIVE_PAD/NEGATIVE_PAD(override or parameters): draws+/-strictly on declared pad(s) (infers the opposite pole only on 2-terminal parts). - Explicit
PIN1_PAD(override or parameter) or polarized inductor: bypasses("R", "C", "L")prefix exclusions soL2(PIN1_PAD="2") gets a Pin 1 marker while non-polarizedL1stays clean. - Auto-detected diode (
diode_ak_labels=True): drawsAandK. - Auto-detected polarized capacitor (
cap_polarity_labels=True): draws+and-. - Generic multi-pin Pin 1: skips
exclude_designator_prefixes, 2-pin parts matchingexclude_two_pin_prefixes(unless opted in via P1–P3 or explicitPIN1_PAD), and single-pad parts (TP*,FID*); picks"1", else"A1", else (for non-connectors only) lowest BGA/LGA grid pad excluding mechanical/shield tabs.
Diode Orientation (DIODES_TOP / DIODES_BOTTOM)
Draws graphical-only polarity glyphs strictly between the anode and cathode pads (so tightly packed inline diodes never collide): axis shaft, filled triangle pointing anode -> cathode, subtype-specific cathode bar (straight for normal/LED, slim opened S-bar with clean outward-returning hooks for Schottky, angled-Z bar for Zener and unidirectional TVS), and LED emission rays. Multi-pin parts without explicit CATHODE_PAD/ANODE_PAD (such as RGB LED D3 and reverse-mount D6) receive + polarity on PIN1_TOP without emitting a misleading 2-pin diode glyph.
DIODES_TOP paired with PIN1_TOP on virtual_fab_layers: colored LEDs (D1 yellow, D2 red, D4 blue, D5 green), 3-pin SOT-23 D7 (ANODE_PAD="1", CATHODE_PAD="3"), 45°-rotated TVS D8, normal D9, Schottky D10, and Zener D11, while D3 and D6 show + only.
| Field | Type | Default | Meaning |
|---|---|---|---|
cathode_parameter | str | "CATHODE_PAD" | Altium parameter naming the cathode pad(s) (comma-separated list supported, e.g. "2,3"). When present, skips auto-detection heuristics; "none"/"false"/"off" suppresses. |
anode_parameter | str | "ANODE_PAD" | Optional Altium parameter naming the anode pad(s); when omitted, remaining pads form the anode group. |
type_parameter | str | "DIODE_TYPE" | Optional diode subtype parameter: "normal", "led", "schottky", "zener", or "tvs". |
color_parameter | str | "DIODE_COLOR" | Optional colour parameter (#RRGGBB hex or named colour) for shaded SVG output. |
default_cathode_pad | str | "2" | Fallback cathode pad name when heuristics detect a 2-pin diode with numeric pads "1" and "2". |
color_mode | "shaded" | "monochrome" | "shaded" | SVG rendering mode. "shaded" paints subtype/LED fill colours with darkened outlines and a white contrast halo. |
cathode_pad_names | tuple[str, ...] | ("K", "C", "CATHODE", "CAT", "-") | Pad designator names recognized automatically as cathode pads during heuristic detection. |
designator_prefixes | tuple[str, ...] | ("D", "LED") | Designator prefixes matched during 2-terminal auto-detection. |
keywords | tuple[str, ...] | ("diode", "led", "schottky", "tvs", "zener", "1n") | Word-boundary keywords scanned across description, comment, footprint, and parameters during auto-detection. |
visibility_mode | "all" | "explicit" | "all" | "all" draws all detected diodes automatically; "explicit" draws only P1/P2/P3 opt-ins (overrides.<ref>.enabled=True, visibility.overrides.<ref>.diodes=True, or DIODE_SYMBOL="true"). |
overrides | Mapping[str, DiodeOverride] | {} | Per-component DiodeOverride(enabled=None, cathode_pad=None, anode_pad=None, diode_type=None, color=None) overrides (enabled=None is semantic-only). |
Passive Orientation & Symbol Layers (CAPACITORS_*, INDUCTORS_*, RESISTORS_*)
Three dedicated passive-component virtual layers render clean schematic-grade symbols scaled from pad center to pad center (leads terminate at each terminal's pad center):
Full-board overview of CAPACITORS_TOP, INDUCTORS_TOP (visibility_mode="all"), and RESISTORS_TOP on virtual_fab_layers.
Zoomed close-up — CAPACITORS_TOP (visibility_mode="all"): polarized tantalum C1, aluminum electrolytic C2 (flat positive plate, curved negative plate, + sign), and non-polarized MLCC C3 (twin parallel plates), with leads terminating at exact pad centers.
Zoomed close-up — INDUCTORS_TOP (L1 non-polarized 4-lobe coil, L2 polarized coil with pin 2 winding-start dot) and RESISTORS_TOP (R1 IEEE 6-peak zig-zag), all scaled cleanly from pad center to pad center.
Zoomed close-up — RESISTORS_TOP with style="box" (IEC rectangular body on R1) beside polarized inductor L2.
Capacitors (CAPACITORS_TOP / CAPACITORS_BOTTOM, .GCT / .GCB)
By default (visibility_mode="polarized_only"), emits only polarized capacitors (tantalum, electrolytic, polymer, supercap, or any capacitor with explicit POSITIVE_PAD/NEGATIVE_PAD or +/-/A/K pads) with a flat positive plate, curved negative plate, and optional + marker. Set visibility_mode="all" (or legacy include_non_polarized=True) to also draw parallel-plate symbols on ceramic/film capacitors (C3), or visibility_mode="explicit" to draw only P1/P2/P3 opt-ins (e.g. CAPACITOR_SYMBOL="true").
| Field | Type | Default | Meaning |
|---|---|---|---|
positive_parameter | str | "POSITIVE_PAD" | Component parameter naming the positive pad ("none"/"false" clears the explicit positive pad; use CAPACITOR_SYMBOL="false" to hide the symbol, or CAPACITOR_TYPE="none" to suppress capacitor classification). |
negative_parameter | str | "NEGATIVE_PAD" | Component parameter naming the negative pad. |
type_parameter | str | "CAPACITOR_TYPE" | Optional type parameter ("polarized", "tantalum", "electrolytic", "non_polarized", "mlcc", "none", etc.). |
color_parameter | str | "CAPACITOR_COLOR" | Optional SVG accent colour (#RRGGBB or named colour). |
default_positive_pad | str | "1" | Fallback positive pad name for polarized 2-pin capacitors with numeric pads "1"/"2". |
visibility_mode | "all" | "polarized_only" | "explicit" | None | None (effective "polarized_only") | Visibility policy ("polarized_only" default, "all" includes non-polarized caps, "explicit" draws only P1/P2/P3 opt-ins). |
include_non_polarized | bool | False | (Legacy bridge) Used only when visibility_mode is None: False -> "polarized_only", True -> "all". |
show_plus_sign | bool | True | Draw a crisp + symbol on the positive side of polarized capacitors. |
color_mode | "shaded" | "monochrome" | "shaded" | SVG paint mode (default teal #0D9488 fill / #0F766E stroke with white contrast halo). |
designator_prefixes | tuple[str, ...] | ("C",) | Designator prefixes matched during 2-terminal capacitor auto-detection. |
keywords | tuple[str, ...] | ("capacitor", "tantalum", "tant", "electrolytic", "elec", "supercap", "polymer") | Word-boundary keywords scanned across description, comment, footprint, and parameters. |
overrides | Mapping[str, CapacitorOverride] | {} | Per-component CapacitorOverride(enabled=None, positive_pad=None, negative_pad=None, polarized=None, color=None) (enabled=None is semantic-only). |
Inductors (INDUCTORS_TOP / INDUCTORS_BOTTOM, .GLT / .GLB)
Draws a 4-lobe semicircular coil glyph between the inductor's pads, plus a filled winding-start polarity dot whenever the inductor is polarized. By default (visibility_mode="polarized_only"), emits only polarized inductors (parts with INDUCTOR_POLARITY_PAD, PIN1_PAD such as L2, or INDUCTOR_TYPE="polarized" / "coupled" / "dot" / "start"). Set visibility_mode="all" (or legacy include_non_polarized=True) to also draw coils on non-polarized inductors (L1), or visibility_mode="explicit" to draw only P1/P2/P3 opt-ins (e.g. INDUCTOR_SYMBOL="true").
| Field | Type | Default | Meaning |
|---|---|---|---|
polarity_parameter | str | "INDUCTOR_POLARITY_PAD" | Primary component parameter naming the winding-start pad ("none"/"false" forces non-polarized; use INDUCTOR_SYMBOL="false" to hide the symbol, or INDUCTOR_TYPE="none" to suppress inductor classification). |
pin1_fallback_parameter | str | "PIN1_PAD" | Secondary fallback parameter when INDUCTOR_POLARITY_PAD is absent (used by L2 PIN1_PAD="2"). |
type_parameter | str | "INDUCTOR_TYPE" | Optional type parameter ("polarized", "coupled", "dot", "start", "non_polarized", "none", etc.). |
color_parameter | str | "INDUCTOR_COLOR" | Optional SVG accent colour. |
visibility_mode | "all" | "polarized_only" | "explicit" | None | None (effective "polarized_only") | Visibility policy ("polarized_only" default, "all" includes non-polarized inductors, "explicit" draws only P1/P2/P3 opt-ins). |
include_non_polarized | bool | False | (Legacy bridge) Used only when visibility_mode is None: False -> "polarized_only", True -> "all". |
color_mode | "shaded" | "monochrome" | "shaded" | SVG paint mode (default violet #7C3AED fill / #5B21B6 stroke with white contrast halo). |
designator_prefixes | tuple[str, ...] | ("L", "FB", "IND") | Designator prefixes matched during 2-terminal inductor auto-detection. |
keywords | tuple[str, ...] | ("inductor", "choke", "ferrite", "coil") | Word-boundary keywords scanned across description, comment, footprint, and parameters. |
overrides | Mapping[str, InductorOverride] | {} | Per-component InductorOverride(enabled=None, polarity_pad=None, polarized=None, color=None) (enabled=None is semantic-only). |
Resistors (RESISTORS_TOP / RESISTORS_BOTTOM, .GRT / .GRB)
Draws a 2-terminal resistor symbol scaled from pad center to pad center in either IEEE zig-zag (style="zigzag", default) or IEC rectangular box (style="box").
| Field | Type | Default | Meaning |
|---|---|---|---|
style | "zigzag" | "box" | "zigzag" | Default resistor glyph style ("zigzag" IEEE or "box" IEC). |
style_parameter | str | "RESISTOR_STYLE" | Per-component Altium parameter overriding "zigzag" vs "box". |
color_parameter | str | "RESISTOR_COLOR" | Optional SVG accent colour (default emerald #059669). |
color_mode | "shaded" | "monochrome" | "shaded" | SVG paint mode. |
designator_prefixes | tuple[str, ...] | ("R",) | Designator prefixes matched during 2-terminal resistor auto-detection. |
keywords | tuple[str, ...] | ("resistor", "shunt", "thermistor", "ntc", "ptc", "varistor") | Word-boundary keywords scanned across description, comment, footprint, and parameters. |
visibility_mode | "all" | "explicit" | "all" | "all" draws all detected 2-terminal resistors automatically; "explicit" draws only P1/P2/P3 opt-ins (overrides.<ref>.enabled=True, visibility.overrides.<ref>.resistors=True, or RESISTOR_SYMBOL="true"). |
overrides | Mapping[str, ResistorOverride] | {} | Per-component ResistorOverride(enabled=None, style=None, color=None) (enabled=None is semantic-only). |
Assembly Outlines & Designators (ASSEMBLY_OUTLINES_* & ASSEMBLY_DESIGNATORS_*)
Generates fabrication and assembly drawings directly from embedded 3D STEP models, extruded bodies, and board pad geometry:
ASSEMBLY_OUTLINES_TOP and ASSEMBLY_DESIGNATORS_TOP on virtual_fab_layers: J1 rendered in detail HLR via ASSEMBLY_OUTLINE="detail", edge-straddling USB/SMA connectors J2–J5, automatic bounding_box fallback on model-less J6, J7 Tag-Connect excluded via ASSEMBLY_OUTLINE="FALSE" / ASSEMBLY_DESIGNATOR="FALSE", and single-pad circular outlines on FID1–FID4 and TP1–Tp3.
Geometer Fast HLR Algorithm (simple vs detail vs bounding_box)
When embedded STEP 3D models are present on the board, ASSEMBLY_OUTLINES_* uses Geometer Fast HLR (hidden-line removal) to project each unique 3D model onto the board plane (looking down -Z for TOP components, looking up +Z for BOTTOM components):
- Deduplication & Persistent Caching (
AssemblyHlrCache): Components sharing the same embedded STEP binary hash (model.sha256), board side, and local 3D orientation (pose_signature— tilt/flip/standoff, independent of board X/Y/Z-rotation) are projected only once and transformed into every placed instance. Passing anAssemblyHlrCache(used automatically byacr fab,acr pcb-svg, andacr dr) persists bothsimpleanddetaillinework on disk keyed by binary + Geometer build identity so repeat runs take milliseconds. - Three Detail Levels (set globally via
assembly_outlines.detail, per component viaassembly_outlines.overrides[ref].detail, or directly on the Altium part viaASSEMBLY_OUTLINE="simple" | "detail" | "bounding_box"— with fallback parameterASSEMBLY_OUTLINE_DETAILand accepted aliases"outline"→"simple","detailed"/"full"→"detail","bbox"/"box"→"bounding_box"):"simple"(default,0.12 mmstroke): Extracts the clean outer projected silhouette (fast mesh shadow + exact projected boundary arcs and segments) — ideal for uncluttered assembly drawings and Gerber assembly films."detail"(0.08 mmstroke): Retains full visible HLR boundaries, creases, silhouettes, pin outlines, and extruded body holes (suppressing coplanar seams) — ideal for detailed mechanical/connector inspection (such asJ1on the showcase board)."bounding_box": Skips Geometer 3D projection completely and strokes the axis-aligned pad/drill bounding box — instantaneous and zero-dependency.
- Graceful Geometry Fallback Chain (per visible fitted component):
- Embedded STEP 3D model via Geometer Fast HLR (unless
detail="bounding_box"). - Extruded 3D component body polygon (
FabBody.outline). - Single-pad shape (
pad_shape): for model-less single-pad parts (such asFID1–FID4andTP1–Tp3), strokes the exact pad/hole outline preserving circular arcs and capsules. - Multi-pad bounding box (
pad_bounds): for model-less multi-pad parts (such asJ6) or whendetail="bounding_box", strokes the bounding box around all pads and drills.
- Embedded STEP 3D model via Geometer Fast HLR (unless
detail="simple" (default) — crisp outer HLR silhouettes across the board (J1 elevated to detail via its ASSEMBLY_OUTLINE="detail" parameter).
detail="detail" — full visible HLR creases, pin outlines, and internal 3D connector features.
detail="bounding_box" — instantaneous pad/drill extent fallback with zero 3D STEP projection.
AssemblyOutlineLayerOptions (virtual_options.assembly_outlines)
| Field | Type | Default | Meaning |
|---|---|---|---|
detail | "simple" | "detail" | "bounding_box" | "simple" | Default HLR/outline detail mode across the board. |
stroke_width_mm | float | 0.12 | Stroke width in mm for simple and bounding_box outlines. |
detail_stroke_width_mm | float | 0.08 | Stroke width in mm for detail HLR internal linework. |
dnp_crossout_stroke_width_mm | float | None | None | Stroke width in mm for the diagonal X lines drawn over DNP parts when dnp_mode="crossout". None (default) auto-scales proportionally to each component's body size (0.15 mm–0.35 mm, floor 1.25× stroke_width_mm). |
visibility_mode | "all" | "explicit" | "all" | "all" draws all eligible component outlines; "explicit" draws only P1/P2/P3 opt-ins. |
overrides | Mapping[str, AssemblyOutlineOverride] | {} | Per-component AssemblyOutlineOverride(enabled=None, detail=None) overrides (case-insensitive designator lookup; enabled=None is semantic-only). |
AssemblyDesignatorLayerOptions (virtual_options.assembly_designators)
| Field | Type | Default | Meaning |
|---|---|---|---|
min_font_size_mm | float | 0.08 | Minimum fitted designator height in millimetres; labels smaller than this are omitted. |
max_font_size_mm | float | 2.40 | Maximum fitted designator height in millimetres. |
fill_ratio | float | 0.78 | Fraction of the available outline box filled by the designator (0 to 1). |
visibility_mode | "all" | "explicit" | "all" | "all" draws all eligible component designators; "explicit" draws only P1/P2/P3 opt-ins. |
overrides | Mapping[str, bool] | {} | Per-component visibility overrides (True/False) for fitted designators. |
Assembly designators (ASSEMBLY_DESIGNATORS_TOP / BOTTOM) fit each component's reference designator inside its outline polygon (including single round pad outlines, falling back to convex hull or pad box), subtracting board cutouts so text never lands over empty air, choosing between the component's primary rotation and +90° for maximum legibility, and mirroring X on the bottom side.
Pad Designator Labels (PAD_LABELS_TOP / PAD_LABELS_BOTTOM, .GPLT / .GPLB)
Fits each copper pad's designator (1, A1, VCC, K, …) inside its pad land on the requested side using either built-in Altium vector stroke fonts or outlined TrueType glyphs, with optional pure geometric knockout=True (boolean difference against the pad shape preserving counter islands such as A, 0, 8, and B).
PAD_LABELS_TOP / PAD_LABELS_BOTTOM work identically across:
.PcbDocboards (FabView): labels every fitted component pad onside(honoringvisibility, DNP status, andPAD_LABELSparameter overrides) plus free board pads on that side..PcbLibfootprints (footprint_view(footprint)): labels every footprint pad directly when rendering footprint SVGs or baking onto library mechanical layers.- All output formats: lowers identically to Gerber X2 (
OtherDrawing,Top/Bottom Pad Labels,.GPLT/.GPLB), IPC-2581B (ASSEMBLY/TOP|BOTTOM), SVG (stroke, TrueType, orknockout=Trueeven-odd regions), and baked Altium mechanical layers.
Full-board overview — PAD_LABELS_TOP (font_mode="stroke", #C2410C rendered on top of dimmed HLR outlines and copper pads).
Zoomed close-up — font_mode="stroke", knockout=False on BGA U3 (A1..H8).
Zoomed close-up — font_mode="stroke", knockout=True on BGA U3, preserving interior counter islands (A, B, D, 0, 6, 8) as pure planar holes.
Zoomed close-up — font_mode="truetype" (Arial), knockout=True across QFP-64 U2 and adjacent SMD pads.
Pad Label Orientation Modes (pad vs orthogonal vs upright)
Compare how pad_labels.orientation handles horizontal/vertical QFP-64 leads, the 45°-rotated diode (1/2), elongated inductor pads, and nearly-square SMD pads (< 1.25:1 ratio stays 0° upright):
orientation="pad" (default) — aligns each label along its pad's long axis: QFP horizontal pins (1–16, 33–48) stay 0°, QFP vertical pins (17–32, 49–64) align 90°, and the 45°-rotated diode follows its 45° pad angle.
orientation="orthogonal" — snaps every elongated pad's long axis strictly to 0° or 90° (QFP vertical pins stay 90°, while the 45°-rotated diode snaps to 0°).
orientation="upright" — keeps every pad label strictly horizontal (0°), automatically scaling each glyph to fit both the pad's width and height (including vertical QFP leads and rotated pads).
| Field | Type | Default | Meaning |
|---|---|---|---|
font_mode | "stroke" | "truetype" | "stroke" | Text renderer override for pad labels (inherits top-level VirtualLayerOptions.font_mode when left at default). |
stroke_font | "sans_serif" | "serif" | "default" | "sans_serif" | Built-in Altium vector stroke font when font_mode="stroke". |
font_family | str | "Arial" | TrueType font family when font_mode="truetype". |
font_bold | bool | True | Bold weight flag when font_mode="truetype". |
orientation | "pad" | "orthogonal" | "upright" | "pad" | Label orientation policy: "pad" aligns labels along each pad's long axis (normalized upright (-90°, +90°], so horizontal QFP/SMD pads stay 0° for both 1–9 and 10+, vertical pads align 90°, and angled pads follow their rotation), "orthogonal" snaps the pad's long axis to 0° or 90° only, and "upright" keeps every label strictly horizontal (0°) scaled to the pad's width and height. |
knockout | bool | False | When True, punches each pad designator glyph out of the copper pad polygon as a pure GeomPlanarRegion with interior holes and counter islands. |
fill_ratio | float | 0.70 | Fraction of available pad extent filled by the fitted label. |
min_height_nm | float | 60_000.0 (0.06 mm) | Minimum fitted label height in nanometres; labels smaller than this are omitted. (In JSONC configs fab.jsonc / vdoc.jsonc / pcb.svg.config, this field is specified in millimetres as min_height_mm, default 0.06.) |
max_height_nm | float | 2_000_000.0 (2.0 mm) | Maximum fitted label height in nanometres. (In JSONC configs, specified in millimetres as max_height_mm, default 2.0.) |
stroke_width_ratio | float | 0.14 | Stroke thickness as a fraction of fitted label height in "stroke" mode. |
skip_empty_designators | bool | True | Omit pads with blank designators (set False to label them "?"). |
skip_mechanical_pads | bool | False | Skip pads whose designator matches mechanical/shield patterns (MH*, MP*, MTG*, SH*, SHIELD*, TAB*, CASE*, etc.). |
include_through_hole | bool | True | Include through-hole pads (plated_pad / non_plated_pad) as well as SMD pads. |
visibility | ComponentVisibilityPolicy | None | None | Optional override policy (defaults to VirtualLayerOptions.visibility). |
visibility_mode | "all" | "explicit" | "all" | "all" labels all eligible pads; "explicit" labels only components opted in via P1/P2/P3 (overrides, visibility.overrides.<ref>.pad_labels, or PAD_LABELS="true"). |
overrides | Mapping[str, bool] | {} | Per-component visibility overrides (True/False, case-insensitive designator lookup). |
color_mode | "shaded" | "monochrome" | "shaded" | SVG rendering mode (default sky blue #0284C7; custom halos can be supplied via SvgWriterOptions.virtual_style_overrides). |
STEP HLR Caching, Progress Callbacks & VirtualItemStyle
- Persistent STEP HLR caching (
hlr_cache): Pass any object implementingAssemblyHlrCache(load(model_hash, side, pose_signature) -> HlrProjectedGeometry | Noneandstore(model_hash, side, pose_signature, geometry) -> None) to reuse Geometer Fast HLR projections across runs.HlrProjectedGeometrystores bothoutline_segments/outline_arcs(detail="simple") anddetail_segments/detail_arcs(detail="detail") in local millimetres. - Progress reporting (
progress): Pass aCallable[[str], None]callback to receive concise status messages whenever Geometer projects or hits cache for embedded STEP models (e.g.geometer (top): 28 STEP models (28 cached) in 0.08 s). - Per-item SVG style (
VirtualItemStyle): Each entry inVirtualLayerResult.stylesmaps a placed itemidtoVirtualItemStyle(fill=None, stroke=None, halo_color=None, halo_width_nm=None, opacity=None, dash_array_nm=()). SVG lowering applies these styles in shaded mode (and merges anySvgWriterOptions.virtual_style_overrideskeyed by"*"or itemkind); Gerber and IPC-2581 ignorestylesand lower pure vector geometry.
Baking Virtual Layers To Mechanical Layers
altium_monkey.fab provides a built-in mechanical-layer baking engine for both .PcbDoc boards and .PcbLib footprint libraries, paired with an occupied-layer collision detector and the turnkey acr vdoc CLI command (backed by vdoc.jsonc and MCO):
detect_mechanical_layer_collisions(doc_or_lib, options, *, footprints=None): Inspects every target mechanical layer before mutation and returnstuple[MechanicalLayerCollision, ...]. A layer is considered safe to refresh when it is empty or contains no 3Dcomponent_bodiesand already carries a previously bakedVirtual ...display name; any layer holding 3D bodies or non-virtual primitives is flagged as a collision.bake_virtual_layers_to_pcbdoc(pcbdoc, *, fab_view=None, parameters=None, variant=None, options): Computes all requested virtual layers before mutatingpcbdoc, clears prior virtual primitives and virtual unions idempotently (clear_existing=True), assigns readable layer names (Virtual Pin 1 Top, …) and top/bottom mirror pairs (set_layer_pairs=True), attaches component-scoped primitives (PIN1_*,DIODES_*, passives,ASSEMBLY_OUTLINES_*,PAD_LABELS_*) to their owningcomponent_index, groups board-levelCUTOUTSin a User Union (Virtual_Cutouts), and groups freeASSEMBLY_DESIGNATORS_*primitives with their owning component inVirtual_Designators_<ref>without clobbering pre-existing user or smart unions.bake_virtual_layers_to_pcblib(pcblib, *, footprints=None, options, on_stage=None, on_layer_done=None): BakesASSEMBLY_OUTLINES_TOP(including embedded STEP HLR with a shared in-memory HLR cache across footprints),PIN1_TOP,PAD_LABELS_TOP, and family layers onto selected or all footprints in a.PcbLib.
| Field | Type | Default | Meaning |
|---|---|---|---|
layer_map | Mapping[str, str | MechanicalLayerTarget] | (required) | Maps canonical virtual layer keys ("CUTOUTS", "PIN1_TOP", …) to target mechanical layer tokens ("MECHANICAL35", …) or MechanicalLayerTarget(layer, name, pair_with). |
virtual_options | VirtualLayerOptions | VirtualLayerOptions() | Virtual-layer generation options shared across all baked layers. |
clear_existing | bool | True | Idempotently remove prior virtual primitives and virtual unions on target layers before writing. |
clear_only | bool | False | Clear previously baked virtual primitives and virtual unions without redrawing new geometry. |
remove_cleared_layers | bool | True | When clear_only=True, disable/hide emptied virtual mechanical layers (MECHENABLED=FALSE, USEDBYPRIMS=FALSE, unpair, reset default name). |
set_layer_names | bool | True | Assign readable mechanical layer display names (e.g. "Virtual Pin 1 Top"). |
set_layer_pairs | bool | True | Configure Top/Bottom Altium mechanical layer mirror pairs for paired virtual layers (idempotent, deduplicating stale pairs). |
cutouts_union_name | str | "Virtual_Cutouts" | Altium User Union name grouping board-level CUTOUTS primitives. |
union_designators_with_component | bool | True | Group free ASSEMBLY_DESIGNATORS_* primitives with their owning component in Virtual_Designators_<ref>. |
designator_mode | "strokes" | "native_text" | "strokes" | "strokes" works on any layer M1..M53; "native_text" emits native Altium Text records (limited to legacy M1..M16). |
circle_segments | int | 24 | Polygonal segments used when approximating circular knockout/area regions. |
min_stroke_width_mils | float | 0.5 | Minimum track width clamp in mils for baked stroke primitives. |
Both bake_virtual_layers_to_pcbdoc and bake_virtual_layers_to_pcblib also accept optional on_stage(stage: str) and on_layer_done(layer_report: BakeLayerReport) callbacks for live progress reporting, and return a BakeVirtualLayersReport containing layers, total_cleared, total_written, unions_created, footprints_processed, layers_removed (layers hidden by clear_only=True), and warnings.
from altium_monkey import AltiumPcbDoc, AltiumPcbLib
from altium_monkey.fab import (
BakeVirtualLayersOptions,
VirtualLayerOptions,
bake_virtual_layers_to_pcbdoc,
bake_virtual_layers_to_pcblib,
detect_mechanical_layer_collisions,
)
# Bake into a .PcbDoc using high mechanical layers (M35..M44) above M1..M32
board = AltiumPcbDoc.from_file("board.PcbDoc")
bake_opts = BakeVirtualLayersOptions(
layer_map={
"CUTOUTS": "MECHANICAL35",
"PIN1_TOP": "MECHANICAL36",
"PIN1_BOTTOM": "MECHANICAL37",
"DIODES_TOP": "MECHANICAL38",
"ASSEMBLY_OUTLINES_TOP": "MECHANICAL40",
"ASSEMBLY_DESIGNATORS_TOP": "MECHANICAL42",
"PAD_LABELS_TOP": "MECHANICAL44",
},
virtual_options=VirtualLayerOptions(),
clear_existing=True,
set_layer_names=True,
set_layer_pairs=True,
designator_mode="strokes", # "strokes" (any M1..M53) or "native_text" (M1..M16)
)
collisions = detect_mechanical_layer_collisions(board, bake_opts)
if collisions:
for col in collisions:
print(f"Collision on {col.mechanical_layer} ({col.current_name}): {col.total_primitives} items")
else:
report = bake_virtual_layers_to_pcbdoc(board, options=bake_opts)
print(f"Wrote {report.total_written} primitives, {report.unions_created} unions")
board.save("out/board_with_vdoc.PcbDoc")
# Bake outlines, Pin 1, and pad labels directly into a .PcbLib
lib = AltiumPcbLib.from_file("footprints.PcbLib")
lib_opts = BakeVirtualLayersOptions(
layer_map={
"ASSEMBLY_OUTLINES_TOP": "MECHANICAL40",
"PIN1_TOP": "MECHANICAL36",
"PAD_LABELS_TOP": "MECHANICAL44",
}
)
lib_report = bake_virtual_layers_to_pcblib(lib, options=lib_opts)
print(f"Baked {lib_report.footprints_processed} footprints ({lib_report.total_written} primitives)")
lib.save("out/footprints_with_vdoc.PcbLib")For CLI and automation workflows:
- Turnkey CLI: run
acr vdocwithvdoc.jsonc(safeMECHANICAL35..51defaults, siblingfab.jsoncinheritance,.bakbackup, collision guard,--dry-run,--force, and--clear/--clear-onlyto strip previously baked virtual primitives and unions without redrawing). - MCO automation: use
pcbdoc.bake_virtual_layersandpcblib.bake_virtual_layersinacr mco.
Inspecting VirtualLayerResult Directly
You can still call view.virtual_layer(key, options) directly whenever you want to inspect the computed geometry in Python or build custom lowerings:
from altium_monkey import AltiumPcbDoc
from altium_monkey.fab import VirtualLayerOptions
board = AltiumPcbDoc.from_file("board.PcbDoc")
view = board.fab().view()
result = view.virtual_layer("PAD_LABELS_TOP", VirtualLayerOptions())
print(result.key, result.color_mode, len(result.placed), len(result.styles))
# Convert placed items into the canonical FabLayerItems contract (nanometres, +Y up)
layer_items = result.to_fab_layer_items()
strokes = layer_items.strokes or ()
areas = layer_items.areas or ()
lands = layer_items.lands or ()
print(f"strokes={len(strokes)}, areas={len(areas)}, lands={len(lands)}")Tip: Compute all needed
view.virtual_layer(...)results before mutating anAltiumPcbDocmanually.FabViewenforces source-snapshot immutability and raisesPcbFabQueryError("mutated_source_document")if you query an existing view after adding or removing primitives on the underlying board. (bake_virtual_layers_to_pcbdochandles this ordering automatically.)
See the full runnable workflow in fab_virtual_layers_to_mechanical.
Runnable Examples
fab_virtual_layers_to_mechanical: clear Mechanical 11–15, computeCUTOUTS,PIN1_TOP,DIODES_TOP,ASSEMBLY_OUTLINES_TOP, andASSEMBLY_DESIGNATORS_TOP, bake them onto the board's mechanical layers, save a new.PcbDoc, and render an SVG preview.fab_release_package: Gerber layer selection, dual-key customextensions, virtual layers,profile_cutouts=True, IPC-2581B virtual/document layers, and shaded virtual overlay SVGs.fab_view_query_and_fonts: queryingview.virtual_layer(...), inspectingto_fab_layer_items(), and rendering virtual-layer SVGs alongsideFabViewJSON round-trip.