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

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:

virtual_composite_dark.svg
Open SVG
Composite virtual fab layers rendered on the virtual_fab_layers showcase board

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 KeyDisplay NameRoleSideGerber ExtSVG Colour
CUTOUTSBoard Cutoutscutoutsboard.GCU#D71920
PIN1_TOPTop Pin 1 Markerspin1top.GP1T#1479CC
PIN1_BOTTOMBottom Pin 1 Markerspin1bottom.GP1B#1479CC
DIODES_TOPTop Diode Orientationdiodestop.GDT#E67E22
DIODES_BOTTOMBottom Diode Orientationdiodesbottom.GDB#E67E22
CAPACITORS_TOPTop Capacitorscapacitorstop.GCT#0D9488
CAPACITORS_BOTTOMBottom Capacitorscapacitorsbottom.GCB#0D9488
INDUCTORS_TOPTop Inductorsinductorstop.GLT#7C3AED
INDUCTORS_BOTTOMBottom Inductorsinductorsbottom.GLB#7C3AED
RESISTORS_TOPTop Resistorsresistorstop.GRT#059669
RESISTORS_BOTTOMBottom Resistorsresistorsbottom.GRB#059669
ASSEMBLY_OUTLINES_TOPTop Component Outlinesassembly_drawingtop.GAT#1F2937
ASSEMBLY_OUTLINES_BOTTOMBottom Component Outlinesassembly_drawingbottom.GAB#1F2937
ASSEMBLY_DESIGNATORS_TOPTop Component Designatorsassembly_drawingtop.GADT#111827
ASSEMBLY_DESIGNATORS_BOTTOMBottom Component Designatorsassembly_drawingbottom.GADB#111827
PAD_LABELS_TOPTop Pad Labelspad_labelstop.GPLT#0284C7
PAD_LABELS_BOTTOMBottom Pad Labelspad_labelsbottom.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:

Quick Start Across Outputs

python
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):

python
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

FieldTypeDefaultMeaning
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_familystr"Arial"TrueType font family used when font_mode="truetype".
font_boldboolTrueBold 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.
visibilityComponentVisibilityPolicy(defaults)Unified component inclusion/exclusion rules across all 8 component-scoped families (assembly_outlines, assembly_designators, pin1, pad_labels, diodes, capacitors, inductors, resistors).
cutoutsCutoutLayerOptions(defaults)Scope, hatching, label text, and .GM profile overlay toggle for board cutouts (merging overlapping cutouts cleanly).
pin1Pin1LayerOptions(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.
diodesDiodeLayerOptions(defaults)Diode polarity parameters, heuristics, visibility_mode, SVG shading mode, and per-component overrides.
capacitorsCapacitorLayerOptions(defaults)Capacitor polarity parameters, visibility_mode ("polarized_only" default, legacy include_non_polarized bridge), + sign, SVG shading mode, and per-component overrides.
inductorsInductorLayerOptions(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.
resistorsResistorLayerOptions(defaults)Resistor symbol style ("zigzag" or "box"), parameters, visibility_mode, SVG shading mode, and per-component overrides.
assembly_outlinesAssemblyOutlineLayerOptions(defaults)3D/body outline detail level ("simple", "detail", or "bounding_box"), stroke widths, visibility_mode, and per-component overrides.
assembly_designatorsAssemblyDesignatorLayerOptions(defaults)Fitted assembly designator sizing (min_font_size_mm, max_font_size_mm, fill_ratio), visibility_mode, and per-component overrides.
pad_labelsPadLabelLayerOptions(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_cacheAssemblyHlrCache | NoneNoneOptional persistent cache hook (load/store) for Geometer STEP HLR projections.
progressCallable[[str], None] | NoneNoneOptional callback receiving Geometer STEP projection progress messages.
virtual_fonts_default_dark.svg
Open SVG
Altium classic default stroke font on virtual_fab_layers

font_mode="stroke", stroke_font="default" — Altium classic vector stroke font.

virtual_fonts_sans_dark.svg
Open SVG
Altium sans-serif stroke font on virtual_fab_layers

font_mode="stroke", stroke_font="sans_serif" (default) — clean technical sans-serif vector strokes.

virtual_fonts_serif_dark.svg
Open SVG
Altium serif stroke font on virtual_fab_layers

font_mode="stroke", stroke_font="serif" — Altium serif vector stroke font.

virtual_fonts_truetype_dark.svg
Open SVG
Filled Arial TrueType outline contours on virtual_fab_layers

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:

FieldTypeDefaultMeaning
exclude_kindstuple[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_prefixestuple[str, ...]()Alphabetic designator prefixes excluded across all 8 visibility-governed families (case-insensitive).
outline_parameterstr"ASSEMBLY_OUTLINE"Altium component/footprint parameter controlling ASSEMBLY_OUTLINES_* (accepts boolean tokens or "simple" / "detail" / "bounding_box").
designator_parameterstr"ASSEMBLY_DESIGNATOR"Altium component/footprint parameter controlling ASSEMBLY_DESIGNATORS_*.
pin1_parameterstr"PIN1_MARKER"Altium component/footprint parameter controlling PIN1_*.
pad_labels_parameterstr"PAD_LABELS"Altium component/footprint parameter controlling PAD_LABELS_*.
diode_parameterstr"DIODE_SYMBOL"Altium component/footprint boolean parameter controlling DIODES_*.
capacitor_parameterstr"CAPACITOR_SYMBOL"Altium component/footprint boolean parameter controlling CAPACITORS_*.
inductor_parameterstr"INDUCTOR_SYMBOL"Altium component/footprint boolean parameter controlling INDUCTORS_*.
resistor_parameterstr"RESISTOR_SYMBOL"Altium component/footprint boolean parameter controlling RESISTORS_*.
overridesMapping[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_designatorsfrozenset[str]frozenset()Variant/DNP excluded designators suppressed unconditionally at Gate 1.

Uniform resolution precedence (highest → lowest) across all 8 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:

Define the project's shared virtual-layer rules once in fab.jsonc:

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:

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).

virtual_cutouts_dark.svg
Open SVG
Board Cutouts virtual layer example showing all 7 cutouts on virtual_fab_layers

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).

FieldTypeDefaultMeaning
scope"interior" | "all""interior""interior" selects cutouts strictly inside the outer board boundary (ignoring edge notches); "all" includes every cutout in view.profile().cutouts.
hatchboolTrueDraw clipped parallel vector hatch lines across each selected cutout.
hatch_angle_degfloat45.0Hatch line angle in degrees.
hatch_pitch_mmfloat1.0Spacing between adjacent hatch lines in millimetres (clamped to >= 0.1 mm).
labelstr"CUTOUT"Text fitted inside each cutout; set to "" to omit the label and hatch window.
on_profileboolFalseWhen 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_mmfloat0.10Stroke width in mm for cutout outlines.
hatch_line_width_mmfloat0.075Stroke width in mm for vector hatch lines.
label_max_font_size_mmfloat4.0Maximum fitted height in mm for cutout labels.
label_fill_ratiofloat0.72Fraction of available cutout span filled by the fitted label.
label_rotation_min_gainfloat0.25Minimum 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.

virtual_pin1_dark.svg
Open SVG
Pin 1 and polarity virtual layer rendered on virtual_fab_layers

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:

virtual_pin1_style_dot_dark.svg
Open SVG
Pin 1 style="dot" on U3, U1, and L2

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).

virtual_pin1_style_square_dark.svg
Open SVG
Pin 1 style="square" on U3, U1, and L2

style="square" — pad-rotated square marker aligned with each Pin 1 pad.

virtual_pin1_style_pad_dark.svg
Open SVG
Pin 1 style="pad" on U3, U1, and L2

style="pad" — fills the entire copper Pin 1 pad land shape.

virtual_pin1_style_label_dark.svg
Open SVG
Pin 1 style="pin_label" on U3, U1, and L2

style="pin_label" — fits the actual vector pin name (A1, 1, 2) directly inside the pad.

virtual_pin1_knockout_bga_dark.svg
Open SVG
Pure geometric knockout=True on BGA U3 A1 pad preserving counter island

style="pin_label", knockout=True — close-up of BGA U3 pad A1 showing pure boolean subtraction preserving the triangular counter island inside A.

virtual_pin1_knockout_diode_dark.svg
Open SVG
Pure geometric knockout=True on 45-degree rotated diode D8 A/K pads

knockout=True on 45°-rotated diode D8 and LEDs — A/K glyphs punched cleanly out of rotated pad polygons.

FieldTypeDefaultMeaning
style"dot" | "square" | "pad" | "pin_label""dot"Default Pin 1 marker geometry style.
knockoutboolFalsePunch pin_label, A/K, +/-, and custom symbol glyphs out of the pad shape as pure negative GeomPlanarRegion geometry.
grid_pad_fillboolTrueFill the full pad land for BGA/LGA grid pads (A1, B1, …) in "dot" and "square" modes.
dot_diameter_mmfloat | NoneNoneOptional 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_mmfloat0.40Lower clamp for auto-scaled Pin 1 dot diameter in mm.
max_dot_diameter_mmfloat0.90Upper clamp for auto-scaled Pin 1 dot diameter in mm.
pad_parameterstr"PIN1_PAD"Altium component/footprint parameter naming the Pin 1 pad (e.g. L2 PIN1_PAD="2"), or "NONE"/"OFF"/"FALSE" to suppress.
positive_parameterstr"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_parameterstr"NEGATIVE_PAD"Altium parameter naming explicit - pad(s).
exclude_designator_prefixestuple[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_prefixestuple[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_labelsboolTrueDraw A/K inside anode and cathode pads for detected diodes.
cap_polarity_labelsboolTrueDraw +/- inside positive and negative pads for detected polarized capacitors.
inductor_polarity_markersboolTrueDraw 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.
overridesMapping[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:

  1. Visibility gates (Gate 1 + P1–P5): Unfitted / DNP (not component.fitted or in excluded_designators) always hides; then pin1.overrides[ref].enabled (P1), visibility.overrides[ref].pin1 (P2), PIN1_MARKER parameter (P3), global exclude_kinds / exclude_designator_prefixes (P4), and pin1.visibility_mode ("all" vs "explicit", P5). Explicit P1–P3 opt-ins (True) also bypass pin1.exclude_designator_prefixes and pin1.exclude_two_pin_prefixes in step 6.
  2. Explicit POSITIVE_PAD / NEGATIVE_PAD (override or parameters): draws +/- strictly on declared pad(s) (infers the opposite pole only on 2-terminal parts).
  3. Explicit PIN1_PAD (override or parameter) or polarized inductor: bypasses ("R", "C", "L") prefix exclusions so L2 (PIN1_PAD="2") gets a Pin 1 marker while non-polarized L1 stays clean.
  4. Auto-detected diode (diode_ak_labels=True): draws A and K.
  5. Auto-detected polarized capacitor (cap_polarity_labels=True): draws + and -.
  6. Generic multi-pin Pin 1: skips exclude_designator_prefixes, 2-pin parts matching exclude_two_pin_prefixes (unless opted in via P1–P3 or explicit PIN1_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.

virtual_diodes_dark.svg
Open SVG
Diode Orientation virtual layer rendered on virtual_fab_layers

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.

FieldTypeDefaultMeaning
cathode_parameterstr"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_parameterstr"ANODE_PAD"Optional Altium parameter naming the anode pad(s); when omitted, remaining pads form the anode group.
type_parameterstr"DIODE_TYPE"Optional diode subtype parameter: "normal", "led", "schottky", "zener", or "tvs".
color_parameterstr"DIODE_COLOR"Optional colour parameter (#RRGGBB hex or named colour) for shaded SVG output.
default_cathode_padstr"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_namestuple[str, ...]("K", "C", "CATHODE", "CAT", "-")Pad designator names recognized automatically as cathode pads during heuristic detection.
designator_prefixestuple[str, ...]("D", "LED")Designator prefixes matched during 2-terminal auto-detection.
keywordstuple[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").
overridesMapping[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):

virtual_passives_dark.svg
Open SVG
Full-board overview of Capacitor, Inductor, and Resistor virtual layers on virtual_fab_layers

Full-board overview of CAPACITORS_TOP, INDUCTORS_TOP (visibility_mode="all"), and RESISTORS_TOP on virtual_fab_layers.

virtual_passives_capacitors_dark.svg
Open SVG
Zoomed close-up of Capacitor symbols C1, C2, and C3

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.

virtual_passives_inductors_resistors_dark.svg
Open SVG
Zoomed close-up of Inductors L1, L2 and Resistor R1 (IEEE zig-zag)

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.

virtual_passives_resistor_box_dark.svg
Open SVG
Zoomed close-up of Resistor R1 IEC box style alongside L2

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").

FieldTypeDefaultMeaning
positive_parameterstr"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_parameterstr"NEGATIVE_PAD"Component parameter naming the negative pad.
type_parameterstr"CAPACITOR_TYPE"Optional type parameter ("polarized", "tantalum", "electrolytic", "non_polarized", "mlcc", "none", etc.).
color_parameterstr"CAPACITOR_COLOR"Optional SVG accent colour (#RRGGBB or named colour).
default_positive_padstr"1"Fallback positive pad name for polarized 2-pin capacitors with numeric pads "1"/"2".
visibility_mode"all" | "polarized_only" | "explicit" | NoneNone (effective "polarized_only")Visibility policy ("polarized_only" default, "all" includes non-polarized caps, "explicit" draws only P1/P2/P3 opt-ins).
include_non_polarizedboolFalse(Legacy bridge) Used only when visibility_mode is None: False -> "polarized_only", True -> "all".
show_plus_signboolTrueDraw 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_prefixestuple[str, ...]("C",)Designator prefixes matched during 2-terminal capacitor auto-detection.
keywordstuple[str, ...]("capacitor", "tantalum", "tant", "electrolytic", "elec", "supercap", "polymer")Word-boundary keywords scanned across description, comment, footprint, and parameters.
overridesMapping[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").

FieldTypeDefaultMeaning
polarity_parameterstr"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_parameterstr"PIN1_PAD"Secondary fallback parameter when INDUCTOR_POLARITY_PAD is absent (used by L2 PIN1_PAD="2").
type_parameterstr"INDUCTOR_TYPE"Optional type parameter ("polarized", "coupled", "dot", "start", "non_polarized", "none", etc.).
color_parameterstr"INDUCTOR_COLOR"Optional SVG accent colour.
visibility_mode"all" | "polarized_only" | "explicit" | NoneNone (effective "polarized_only")Visibility policy ("polarized_only" default, "all" includes non-polarized inductors, "explicit" draws only P1/P2/P3 opt-ins).
include_non_polarizedboolFalse(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_prefixestuple[str, ...]("L", "FB", "IND")Designator prefixes matched during 2-terminal inductor auto-detection.
keywordstuple[str, ...]("inductor", "choke", "ferrite", "coil")Word-boundary keywords scanned across description, comment, footprint, and parameters.
overridesMapping[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").

FieldTypeDefaultMeaning
style"zigzag" | "box""zigzag"Default resistor glyph style ("zigzag" IEEE or "box" IEC).
style_parameterstr"RESISTOR_STYLE"Per-component Altium parameter overriding "zigzag" vs "box".
color_parameterstr"RESISTOR_COLOR"Optional SVG accent colour (default emerald #059669).
color_mode"shaded" | "monochrome""shaded"SVG paint mode.
designator_prefixestuple[str, ...]("R",)Designator prefixes matched during 2-terminal resistor auto-detection.
keywordstuple[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").
overridesMapping[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:

virtual_assembly_dark.svg
Open SVG
Assembly Outlines and Assembly Designators virtual layers rendered on virtual_fab_layers

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):

  1. 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 an AssemblyHlrCache (used automatically by acr fab, acr pcb-svg, and acr dr) persists both simple and detail linework on disk keyed by binary + Geometer build identity so repeat runs take milliseconds.
  2. Three Detail Levels (set globally via assembly_outlines.detail, per component via assembly_outlines.overrides[ref].detail, or directly on the Altium part via ASSEMBLY_OUTLINE="simple" | "detail" | "bounding_box" — with fallback parameter ASSEMBLY_OUTLINE_DETAIL and accepted aliases "outline" → "simple", "detailed"/"full" → "detail", "bbox"/"box" → "bounding_box"):
    • "simple" (default, 0.12 mm stroke): 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 mm stroke): Retains full visible HLR boundaries, creases, silhouettes, pin outlines, and extruded body holes (suppressing coplanar seams) — ideal for detailed mechanical/connector inspection (such as J1 on the showcase board).
    • "bounding_box": Skips Geometer 3D projection completely and strokes the axis-aligned pad/drill bounding box — instantaneous and zero-dependency.
  3. Graceful Geometry Fallback Chain (per visible fitted component):
    1. Embedded STEP 3D model via Geometer Fast HLR (unless detail="bounding_box").
    2. Extruded 3D component body polygon (FabBody.outline).
    3. Single-pad shape (pad_shape): for model-less single-pad parts (such as FID1–FID4 and TP1–Tp3), strokes the exact pad/hole outline preserving circular arcs and capsules.
    4. Multi-pad bounding box (pad_bounds): for model-less multi-pad parts (such as J6) or when detail="bounding_box", strokes the bounding box around all pads and drills.
virtual_hlr_simple_dark.svg
Open SVG
Geometer Fast HLR detail="simple" mode on virtual_fab_layers

detail="simple" (default) — crisp outer HLR silhouettes across the board (J1 elevated to detail via its ASSEMBLY_OUTLINE="detail" parameter).

virtual_hlr_detail_dark.svg
Open SVG
Geometer Fast HLR detail="detail" mode on virtual_fab_layers

detail="detail" — full visible HLR creases, pin outlines, and internal 3D connector features.

virtual_hlr_bbox_dark.svg
Open SVG
Geometer Fast HLR detail="bounding_box" fallback mode on virtual_fab_layers

detail="bounding_box" — instantaneous pad/drill extent fallback with zero 3D STEP projection.

AssemblyOutlineLayerOptions (virtual_options.assembly_outlines)

FieldTypeDefaultMeaning
detail"simple" | "detail" | "bounding_box""simple"Default HLR/outline detail mode across the board.
stroke_width_mmfloat0.12Stroke width in mm for simple and bounding_box outlines.
detail_stroke_width_mmfloat0.08Stroke width in mm for detail HLR internal linework.
dnp_crossout_stroke_width_mmfloat | NoneNoneStroke 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.
overridesMapping[str, AssemblyOutlineOverride]{}Per-component AssemblyOutlineOverride(enabled=None, detail=None) overrides (case-insensitive designator lookup; enabled=None is semantic-only).

AssemblyDesignatorLayerOptions (virtual_options.assembly_designators)

FieldTypeDefaultMeaning
min_font_size_mmfloat0.08Minimum fitted designator height in millimetres; labels smaller than this are omitted.
max_font_size_mmfloat2.40Maximum fitted designator height in millimetres.
fill_ratiofloat0.78Fraction 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.
overridesMapping[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:

virtual_pad_labels_dark.svg
Open SVG
Pad Designator Labels full-board overview on virtual_fab_layers

Full-board overview — PAD_LABELS_TOP (font_mode="stroke", #C2410C rendered on top of dimmed HLR outlines and copper pads).

virtual_pad_labels_bga_stroke_dark.svg
Open SVG
Pad Designator Labels stroke positive close-up on BGA U3

Zoomed close-up — font_mode="stroke", knockout=False on BGA U3 (A1..H8).

virtual_pad_labels_bga_knockout_dark.svg
Open SVG
Pad Designator Labels stroke knockout close-up on BGA U3

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.

virtual_pad_labels_qfp_ttf_knockout_dark.svg
Open SVG
Pad Designator Labels TrueType knockout close-up on QFP-64 U2

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):

virtual_pad_labels_orient_pad_dark.svg
Open SVG
Pad Label orientation="pad" on virtual_fab_layers

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.

virtual_pad_labels_orient_orthogonal_dark.svg
Open SVG
Pad Label orientation="orthogonal" on virtual_fab_layers

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°).

virtual_pad_labels_orient_upright_dark.svg
Open SVG
Pad Label orientation="upright" on virtual_fab_layers

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).

FieldTypeDefaultMeaning
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_familystr"Arial"TrueType font family when font_mode="truetype".
font_boldboolTrueBold 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.
knockoutboolFalseWhen True, punches each pad designator glyph out of the copper pad polygon as a pure GeomPlanarRegion with interior holes and counter islands.
fill_ratiofloat0.70Fraction of available pad extent filled by the fitted label.
min_height_nmfloat60_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_nmfloat2_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_ratiofloat0.14Stroke thickness as a fraction of fitted label height in "stroke" mode.
skip_empty_designatorsboolTrueOmit pads with blank designators (set False to label them "?").
skip_mechanical_padsboolFalseSkip pads whose designator matches mechanical/shield patterns (MH*, MP*, MTG*, SH*, SHIELD*, TAB*, CASE*, etc.).
include_through_holeboolTrueInclude through-hole pads (plated_pad / non_plated_pad) as well as SMD pads.
visibilityComponentVisibilityPolicy | NoneNoneOptional 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").
overridesMapping[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

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):

FieldTypeDefaultMeaning
layer_mapMapping[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_optionsVirtualLayerOptionsVirtualLayerOptions()Virtual-layer generation options shared across all baked layers.
clear_existingboolTrueIdempotently remove prior virtual primitives and virtual unions on target layers before writing.
clear_onlyboolFalseClear previously baked virtual primitives and virtual unions without redrawing new geometry.
remove_cleared_layersboolTrueWhen clear_only=True, disable/hide emptied virtual mechanical layers (MECHENABLED=FALSE, USEDBYPRIMS=FALSE, unpair, reset default name).
set_layer_namesboolTrueAssign readable mechanical layer display names (e.g. "Virtual Pin 1 Top").
set_layer_pairsboolTrueConfigure Top/Bottom Altium mechanical layer mirror pairs for paired virtual layers (idempotent, deduplicating stale pairs).
cutouts_union_namestr"Virtual_Cutouts"Altium User Union name grouping board-level CUTOUTS primitives.
union_designators_with_componentboolTrueGroup 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_segmentsint24Polygonal segments used when approximating circular knockout/area regions.
min_stroke_width_milsfloat0.5Minimum 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.

python
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:

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:

python
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 an AltiumPcbDoc manually. FabView enforces source-snapshot immutability and raises PcbFabQueryError("mutated_source_document") if you query an existing view after adding or removing primitives on the underlying board. (bake_virtual_layers_to_pcbdoc handles this ordering automatically.)

See the full runnable workflow in fab_virtual_layers_to_mechanical.

Runnable Examples

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