On This Page (13)
- Usage
- Native Rust CLI Equivalent (k3)
- Positional Arguments
- Options
- How It Works
- Target Auto-Detection & Config Discovery
- Board-Before-Footprint Auto-Detection
- Config Discovery: Boards vs Footprints
- Sibling fab.jsonc virtual_layers Inheritance (Python kcr Only)
- Configuration (vdoc.jsonc)
- Precedence & Conflict Rules
- Quick Examples
- Related
kcr vdoc
Clean legacy documentation-layer artwork (shared with kcr pcb clean) and bake canonical FabView virtual layers (CUTOUTS, PIN1_, DIODES_, CAPACITORS_, INDUCTORS_, RESISTORS_, ASSEMBLY_OUTLINES_, ASSEMBLY_DESIGNATORS_, PAD_LABELS_) onto KiCad F.Fab/B.Fab/User.* layers as grouped native graphic items.
| Command | Aliases | Category | Runtime | Config | Guide |
|---|---|---|---|---|---|
kcr vdoc | kcr virtual-doc | Fabrication & Manufacturing Outputs | Python kcr + Native Rust k3 | <stem>.vdoc.jsonc or vdoc.jsonc (kicad_cruncher.vdoc_config.a0; inherits sibling fab.jsonc) | Fabrication & Outputs: kcr vdoc |
Usage
kcr vdoc [-h] [--doc PCBDOC] [--config CONFIG]
[--init-config] [--force-config]
[--preset {fab,fab-outlines,fab_outlines,user-only,user_only}]
[--layers LAYERS] [--outlines-only] [--map MAP]
[--variant VARIANT] [--clean | --no-clean]
[--clean-only] [--no-rename-layers] [--no-clear]
[--clear-only] [--force] [--no-backup] [--dry-run]
[-o OUTPUT] [--filter FILTER] [--embedded-only]
[--model-search-dir MODEL_SEARCH_DIR] [--ref REF]
[--diode-type {normal,led,schottky,zener,tvs}]
[--cathode-pad CATHODE_PAD] [--anode-pad ANODE_PAD]
[--positive-pad POSITIVE_PAD]
[--negative-pad NEGATIVE_PAD] [--pin1-pad PIN1_PAD]
[--json] [--no-color]
[file]Native Rust CLI Equivalent (k3)
Implemented natively in k3 on top of kicad-monkey-fab with full parity across boards (.kicad_pcb), standalone footprints (.kicad_mod), and footprint libraries (.pretty). See the Native Rust CLI (k3) Parity Guide.
k3 vdoc [--doc PCBDOC] [--config CONFIG] [--init-config] [--force-config] [--preset {fab,fab-outlines,user-only}] [--layers LAYERS] [--fab-only | --outlines-only] [--map MAP] [--variant VARIANT] [--clean | --no-clean] [--clean-only] [--no-rename-layers] [--no-clear] [--clear-only] [--force] [--no-backup] [--dry-run] [-o OUTPUT] [file]Positional Arguments
| Argument | Description |
|---|---|
file | Input .kicad_pcb, .kicad_pro, .kicad_mod, or .pretty footprint library (auto-detects single board/project/library in cwd) |
Options
| Flag | Description |
|---|---|
--doc PCBDOC | Board filename/stem when input is .kicad_pro |
--config CONFIG | Path to vdoc.jsonc |
--init-config | Write a commented default vdoc.jsonc template and exit |
--force-config | Overwrite an existing config file when used with --init-config |
--preset PRESET | Target layer layout preset: fab (default: F.Fab/B.Fab get outlines+designators), fab-outlines (F.Fab/B.Fab get outlines only, designators on User.6/7), or user-only (all virtual layers on User.1..User.9). Choices: fab, fab-outlines, fab_outlines, user-only, user_only. |
--layers LAYERS | Comma-separated canonical virtual layer keys to bake (default: all configured layers) |
--outlines-only, --fab-only | Bake only assembly outlines (F.Fab / B.Fab) without diodes, passives, Pin 1 markers, cutouts, or designators |
--map MAP | Explicit virtual-to-KiCad layer mapping KEY=LAYER (repeatable or comma-separated) |
--variant VARIANT | Board assembly variant name |
--clean | Run shared PCB doc-layer cleanup before baking (overrides vdoc.jsonc clean.enabled). Mutually exclusive with --no-clean. |
--no-clean | Skip PCB doc-layer cleanup before baking. Mutually exclusive with --clean. |
--clean-only | Run the shared PCB doc-layer cleanup without baking new virtual layers |
--no-rename-layers | Do not set KiCad User.N layer display names from baked virtual layers |
--no-clear | Keep previously baked Virtual_* groups instead of clearing before baking |
--clear-only | Remove baked Virtual_* groups for the selected layers without baking new items |
--force | Allow baking onto KiCad layers that still hold non-virtual artwork |
--no-backup | Skip creating a <board>.kicad_pcb.bak backup when editing in place |
--dry-run | Preview cleanup and baked virtual layers without modifying the PCB |
-o, --output OUTPUT | Write the baked .kicad_pcb / .kicad_mod / .pretty to a separate file or directory |
--filter FILTER | Glob filter for .kicad_mod filenames/stems when targeting a .pretty library |
--embedded-only | Resolve only embedded kicad-embed:// STEP models; skip external KiCad 3D libraries |
--model-search-dir MODEL_SEARCH_DIR | Additional 3D model search directory for footprint library mode (repeatable) |
--ref REF | Override transient classification reference (e.g. D1, C1, R1, U1) in footprint mode |
--diode-type DIODE_TYPE | Explicit diode subtype override in footprint library mode. Choices: normal, led, schottky, zener, tvs. |
--cathode-pad CATHODE_PAD | Explicit cathode pad name override (e.g. 1, K) in footprint library mode |
--anode-pad ANODE_PAD | Explicit anode pad name override (e.g. 2, A) in footprint library mode |
--positive-pad POSITIVE_PAD | Explicit positive pad name override in footprint library mode |
--negative-pad NEGATIVE_PAD | Explicit negative pad name override in footprint library mode |
--pin1-pad PIN1_PAD | Explicit Pin 1 pad name override in footprint library mode |
--json | Emit machine-readable JSON report (footprint library mode) |
--no-color | Disable ANSI colors and animated spinners |
How It Works
kcr vdoc (alias kcr virtual-doc) turns FabView virtual fabrication layers into native KiCad graphic primitives (gr_line/gr_arc/gr_circle/gr_poly on boards, or fp_* inside footprints) grouped under Virtual_<LAYER_KEY>. It works seamlessly on:
- KiCad boards & projects (
.kicad_pcb,.kicad_pro) — cleans legacy doc artwork onF.Fab/B.Fab/User.*, assigns readable KiCadUser.Ndisplay names, and bakes up to all 17 canonical virtual layers. - Standalone footprints & footprint libraries (
.kicad_mod,.pretty) — cleans footprint doc layers and bakes 3D HLR assembly outlines, Pin 1 markers, diode/capacitor/inductor/resistor polarity symbols, and pad labels directly into library parts.
In-place edit by default When -o / --output is omitted, kcr vdoc edits the input board or footprint(s) in place after saving a <file>.bak backup (unless --no-backup or backup: false is set). Always preview unfamiliar targets with --dry-run first.
Target Auto-Detection & Config Discovery
Board-Before-Footprint Auto-Detection
When the positional file argument is omitted, kcr vdoc probes the current working directory in strict priority order:
- Single
*.kicad_pro(board mode;--docdisambiguates multi-board projects). - Single
*.kicad_pcb(board mode). - Current directory itself ends in
.pretty(footprint library mode). - Single
*.prettysubdirectory in CWD (footprint library mode). - Single
*.kicad_modfile in CWD (single-footprint mode).
Boards and projects always win over .pretty / .kicad_mod directories when both exist in the same folder.
Config Discovery: Boards vs Footprints
| Mode | Discovery Order | Auto-Creates vdoc.jsonc? |
|---|---|---|
Board (.kicad_pcb / .kicad_pro) | 1. --config <path> (errors if missing)2. <pcb_dir>/<stem>.vdoc.jsonc3. <pcb_dir>/vdoc.jsonc4. Auto-create <pcb_dir>/<stem>.vdoc.jsonc | Yes — unless --dry-run is set |
Footprint (.kicad_mod / .pretty) | 1. --config <path> (errors if missing)2. <search_root>/vdoc.jsonc3. <search_root.parent>/vdoc.jsonc (when search_root is .pretty)4. In-memory defaults | Never |
--init-config writes a commented template (defaulting to <pcb_dir>/<stem>.vdoc.jsonc when a board/project is resolved, else ./vdoc.jsonc) and exits immediately (--force-config overwrites an existing file).
Sibling fab.jsonc virtual_layers Inheritance (Python kcr Only)
In Python kcr vdoc, both board and footprint modes merge "virtual_layers" settings in a three-step ladder (highest wins) — native Rust k3 vdoc does not inherit sibling fab.jsonc:
- Built-in
VirtualLayerSettingsdefaults. - Sibling
fab.jsonc"virtual_layers"block (<pcb_dir>/fab.jsonc, or<search_root>/fab.jsonc-><search_root.parent>/fab.jsoncfor.pretty). vdoc.jsonc"virtual_layers"block (deep-merged overfab.jsonc).
Configuration (vdoc.jsonc)
Schema contract: kicad_cruncher.vdoc_config.a0.
{
"schema": "kicad_cruncher.vdoc_config.a0",
"backup": true, // Write <input>.bak before in-place saves
"clear_existing": true, // Remove prior Virtual_* groups before baking (boards)
"rename_user_layers": true, // Assign readable KiCad User.N display names (boards)
// Layout preset (hyphens or underscores accepted on CLI: fab | fab-outlines | user-only):
// "fab" : F.Fab/B.Fab carry outlines + designators; other layers on User.1..User.5
// "fab_outlines" : F.Fab/B.Fab carry outlines only; designators move to User.6 / User.7
// "user_only" : all virtual layers stay on User.1..User.9 (Eco1/Eco2 for PAD_LABELS_*)
"layer_preset": "fab",
// Shared cleanup engine (same safe engine as `kcr pcb clean`).
// May also be a plain boolean: `"clean": false`.
// Token "target" expands to every KiCad layer referenced in "layers" below.
"clean": {
"enabled": true,
"layers": ["target", "F.Fab", "B.Fab", "User.*"],
"exclude_layers": [
"F.Cu", "B.Cu", "In*.Cu", "Edge.Cuts",
"*.SilkS", "*.Mask", "*.Paste", "*.CrtYd"
],
"footprint_graphics": true,
"board_graphics": true,
"generated_graphics": true,
"hide_reference_fields": true, // Hides visible Reference fields; never deletes mandatory fields
"hide_value_fields": true, // Hides visible Value fields; never deletes mandatory fields
"reset_user_layer_names": true
},
// Explicit virtual-key -> KiCad layer map. Delete this block to inherit from layer_preset.
"layers": {
"CUTOUTS": "User.1",
"PIN1_TOP": "User.2",
"PIN1_BOTTOM": "User.3",
"DIODES_TOP": "User.4",
"DIODES_BOTTOM": "User.5",
"ASSEMBLY_OUTLINES_TOP": "F.Fab",
"ASSEMBLY_OUTLINES_BOTTOM": "B.Fab",
"ASSEMBLY_DESIGNATORS_TOP": "F.Fab",
"ASSEMBLY_DESIGNATORS_BOTTOM": "B.Fab"
// Optional layers: CAPACITORS_*, INDUCTORS_*, RESISTORS_*, PAD_LABELS_TOP/BOTTOM
},
// Optional overrides merged on top of sibling fab.jsonc virtual_layers
"virtual_layers": {}
}Precedence & Conflict Rules
--outlines-only/--fab-onlyvs--layers(hard error):- Combining
--outlines-only(or its alias--fab-only) with--layersfails with exit code1. On boards,--outlines-onlyselectsASSEMBLY_OUTLINES_TOP,ASSEMBLY_OUTLINES_BOTTOM; on footprints, it selectsASSEMBLY_OUTLINES_TOP.
- Combining
- Layer-map resolution (
--presetvsconfig.layersvs--layersvs--map):- Base map: if
--presetis passed, the 9-layer preset map replacesconfig.layers; otherwiseconfig.layersis used (falling back toconfig.layer_preset). - When
--layersis passed: only the listed canonical keys are baked, resolving each key's destination via--map> base map > full preset map. - Subtle board-mode
--maprule: on boards, passing--mapwithout--presetor--layersreplaces the entire layer map so only the mapped keys are baked. Passing--mapwith--presetmerges your--mapentries on top of the preset map. In footprint mode,--mapalways merges over the active base map.
- Base map: if
--clean,--no-clean,--clean-only, and--clear-only:--cleanand--no-cleanare mutually exclusive; when omitted,config.clean.enableddecides (trueby default).--clean-onlyruns only the shared documentation cleanup and saves without baking.--clear-onlyremovesVirtual_*groups on boards without baking — it is rejected on footprint/library targets.
- Snapshot-before-clean safety order:
- In board mode,
kcr vdocbuilds and snapshotsFabViewfrom the untouched board before--cleanremoves legacyF.Fabgeometry or hidesReference/Valueproperties. That guarantees fallback outlines and designator snapshots never disappear during cleanup.
- In board mode,
- Non-virtual collision guard vs
--force:- After cleanup (if enabled) and before baking,
kcr vdocchecks every target layer for remaining non-virtual artwork. If any target layer is still occupied, baking aborts with exit code1and lists every colliding layer. Remap the layer, enable--clean, or pass--forceto bake onto occupied layers.
- After cleanup (if enabled) and before baking,
- Footprint-mode output containment guard & footprint-only flags:
- When
-o <dir>targets a.prettylibrary, the output directory must not nest inside the source.prettydirectory to prevent recursive corruption. - Footprint-only flags (
--filter,--ref,--diode-type,--cathode-pad,--anode-pad,--positive-pad,--negative-pad,--pin1-pad,--embedded-only,--model-search-dir,--json) apply in.kicad_mod/.prettymode and allow deterministic single-part polarity overrides and batch glob filtering.
- When
Quick Examples
# Create a starter vdoc.jsonc (default 'fab' preset + shared clean enabled)
kcr vdoc --init-config --config vdoc.jsonc# Preview cleanup and virtual-layer baking without modifying the board
kcr vdoc board.kicad_pcb --dry-run# Default 'fab' preset: clean F.Fab/B.Fab/User.* and bake outlines+designators onto F.Fab/B.Fab
kcr vdoc board.kicad_pcb -o baked.kicad_pcb# Put outlines on F.Fab/B.Fab and push designators onto User.6/User.7
kcr vdoc board.kicad_pcb --preset fab-outlines -o baked.kicad_pcb# Keep all virtual layers on User.1..User.9 (without touching F.Fab/B.Fab)
kcr vdoc board.kicad_pcb --preset user-only --no-clean -o baked.kicad_pcb# Bake assembly outlines + diode/passive/pin1 symbols into a .pretty library (or --fab-only for outlines only)
kcr vdoc MyParts.pretty -o MyParts_vdoc.pretty
kcr vdoc MyParts.pretty --fab-only -o MyParts_fab.pretty# Run only the shared documentation-layer cleanup without baking
kcr vdoc board.kicad_pcb --clean-only# Clear previously baked Virtual_* groups (boards only)
kcr vdoc board.kicad_pcb --clear-only