kicad monkey v2026.11.30
On This Page (10)

kcr pcb-layer-step

Generate a STEP model for one selected KiCad PCB layer. The default is a bottom-copper fixture-alignment model with highlighted TP* pads, drill overlays, and a separate board-outline body.

CommandAliasesCategoryRuntimeConfigGuide
kcr pcb-layer-step—Fabrication & Manufacturing OutputsPython kcr + Native Rust k3<input_dir>/pcb-layer-step.jsonc (kicad_cruncher.pcb_layer_step.config.a0, auto-created if missing)Fabrication & Outputs: kcr pcb-layer-step

Usage

sh
kcr pcb-layer-step [-h] [-o OUTPUT] [--config CONFIG]
    [--init-config] [--force-config]
    [--doc PCBDOC] [--layer LAYER]
    [--thickness-mm THICKNESS_MM]
    [--z-mm Z_MM]
    [--copper-color COPPER_COLOR]
    [--outline-width-mm OUTLINE_WIDTH_MM]
    [--outline-color OUTLINE_COLOR]
    [--board-cutout-color BOARD_CUTOUT_COLOR]
    [--exclude-poured-polygons]
    [--outline-only] [--no-board-outline]
    [--no-board-cutouts] [--no-hole-cuts]
    [--drill-hole-mode {auto,cut,overlay,none}]
    [--max-boolean-drill-cuts MAX_BOOLEAN_DRILL_CUTS]
    [--drill-hole-color DRILL_HOLE_COLOR]
    [--drill-plated-hole-color DRILL_PLATED_HOLE_COLOR]
    [--drill-non-plated-hole-color DRILL_NON_PLATED_HOLE_COLOR]
    [--drill-overlay-thickness-mm DRILL_OVERLAY_THICKNESS_MM]
    [--drill-minimum-diameter-mm DRILL_MINIMUM_DIAMETER_MM]
    [--drill-hole-shape {solid,ring}]
    [--drill-ring-width-mm DRILL_RING_WIDTH_MM]
    [--drill-plated-ring-shape {annulus,pad}]
    [--no-fuse] [--arc-segments ARC_SEGMENTS]
    [--no-color]
    [file]

Native Rust CLI Equivalent (k3)

Both Python kcr pcb-layer-step and native Rust k3 pcb-layer-step emit self-contained ISO 10303-21 Micro-STEP directly from FabView with zero Geometer or OpenCASCADE dependency.

sh
k3 pcb-layer-step [-o OUTPUT] [--doc PCBDOC] [--layer LAYER] [--thickness-mm MM] [--z-mm MM] [--outline-only] [--no-board-outline] [--no-board-cutouts] [--no-hole-cuts] [--config PATH] [--init-config] [--force-config] [file]

Positional Arguments

ArgumentDescription
fileKiCad project or PCB file (optional if auto-detected in CWD)

Options

FlagDescription
-o, --output OUTPUTOutput directory (default: ./output/pcb-layer-step)
--config CONFIGPath to pcb-layer-step JSON/JSONC config. If omitted, pcb-layer-step looks for pcb-layer-step.jsonc next to each input file; if missing, it creates a template and uses defaults.
--init-configWrite a pcb-layer-step JSONC config template and exit without loading PCB data
--force-configWith --init-config, overwrite an existing config template
--doc, --pcbdoc PCBDOCWith .kicad_pro input, select a specific .kicad_pcb by filename, stem, or relative path
--layer LAYERPCB layer selector: bottom, top, B.Cu, F.Cu, layer id, or layer name
--thickness-mm THICKNESS_MMExtruded layer thickness in millimeters (default: 0.035)
--z-mm Z_MMBottom Z position in millimeters (default: 0)
--copper-color COPPER_COLORSTEP color for selected-layer copper, #RRGGBB or name (default: #B87333)
--outline-width-mm OUTLINE_WIDTH_MMBoard-outline body width in millimeters (default: 0.2)
--outline-color OUTLINE_COLORSTEP color for board outline, #RRGGBB or name (default: #FFFF00)
--board-cutout-color BOARD_CUTOUT_COLORSTEP color for interior board-cutout outline bodies (default: #FFFF00)
--exclude-poured-polygonsExclude poured-zone geometry from the selected layer
--outline-onlyEmit only the board outline body
--no-board-outlineDo not include the board-outline body
--no-board-cutoutsDo not include separate interior board-cutout outline bodies
--no-hole-cutsDo not subtract or overlay pad/via drill holes in copper geometry
--drill-hole-mode DRILL_HOLE_MODEDrill-hole handling: auto cuts small boards, cut uses booleans, overlay uses visible disks/rings, none omits them. Choices: auto, cut, overlay, none.
--max-boolean-drill-cuts MAX_BOOLEAN_DRILL_CUTSAuto mode uses boolean drill cuts up to this count (default: 128)
--drill-hole-color DRILL_HOLE_COLORSTEP color for drill overlays, #RRGGBB or name (default: #FFFFFF)
--drill-plated-hole-color DRILL_PLATED_HOLE_COLORSTEP color for plated drill overlays when plating colors are split
--drill-non-plated-hole-color DRILL_NON_PLATED_HOLE_COLORSTEP color for non-plated drill overlays when plating colors are split
--drill-overlay-thickness-mm DRILL_OVERLAY_THICKNESS_MMThickness for fast drill-overlay bodies in millimeters (default: 0.001)
--drill-minimum-diameter-mm DRILL_MINIMUM_DIAMETER_MMOnly render drills larger than this diameter in millimeters
--drill-hole-shape DRILL_HOLE_SHAPEOverlay drill shape: solid disk/capsule or annular ring. Choices: solid, ring.
--drill-ring-width-mm DRILL_RING_WIDTH_MMAnnular ring width when --drill-hole-shape ring is active
--drill-plated-ring-shape DRILL_PLATED_RING_SHAPEPlated drill ring source: fixed annulus or full pad shape. Choices: annulus, pad.
--no-fusePreserve primitive-level copper and board-outline regions instead of requesting 2D copper fusion
--arc-segments ARC_SEGMENTSFallback sampling resolution for elliptical pads and slots (default: 32)
--no-colorDisable ANSI colors and animated spinners

How It Works

kcr pcb-layer-step generates compact, colored ISO 10303-21 Micro-STEP alignment models (.step + companion .json manifest) for mechanical enclosure checks, pogo-pin test fixtures, and mating-board alignment — directly from FabView with zero Geometer or OpenCASCADE dependency.

Every model uses:

Input & Config Discovery

  1. Input resolution:
    • Accepts .kicad_pcb or .kicad_pro (use --doc <board> to pick one board in a multi-board project).
    • If omitted, auto-detects a single *.kicad_pro in CWD, falling back to a single *.kicad_pcb.
  2. pcb-layer-step.jsonc discovery (always auto-creates when missing):
    • --init-config writes the commented template to --config <path> (or <input_dir>/pcb-layer-step.jsonc, or ./pcb-layer-step.jsonc when no input is given) and exits without loading PCB data (--force-config overwrites an existing file).
    • Explicit --config <path> auto-creates the template at that path if it does not yet exist, then loads it.
    • Without --config, kcr pcb-layer-step looks for <input_dir>/pcb-layer-step.jsonc and auto-creates it if missing. Legacy .json filenames are not probed.

Configuration (pcb-layer-step.jsonc)

Schema contract: kicad_cruncher.pcb_layer_step.config.a0. One config can emit multiple independent STEP files under outputs[].

jsonc
{
  "schema": "kicad_cruncher.pcb_layer_step.config.a0",

  // Shared settings inherited by every entry in outputs[].
  "defaults": {
    "pcbdoc": null,                  // Optional .kicad_pcb selector for .kicad_pro inputs
    "layer": "bottom",               // "bottom" | "top" | "B.Cu" | "F.Cu" | KiCad layer name/id
    "z_mm": 0.0,                     // Base Z plane (mm)
    "thickness_mm": 0.035,           // Nominal copper extrusion thickness (mm)
    "include_board_outline": true,
    "board_outline": {
      "color": "#FFFF00",            // #RRGGBB or named color (red, blue, copper, yellow, ...)
      "cutout_color": "#FFFF00",
      "cutouts": true,               // Emit separate bodies around interior board cutouts
      "width_mm": 0.2,               // Outline stroke width (mm)
      "fuse": true                   // Request 2D planar fusion for outline bodies
    }
  },

  "outputs": [
    {
      "name": "fixture_alignment",
      // Tokens: {board}, {Board}, {layer}, {Layer}, {output}, {Output}
      "output_step": "{board}__fixture_alignment.step",
      "features": {
        "defaults": { "color": "#B87333" },
        "component_pads": {
          "mode": "matching_designators",   // "none" | "all" | "matching_designators"
          "include_designators": ["TP*", "M*"], // Case-insensitive shell globs
          "color": "#B87333",
          "step_body_name": "component_pads",
          "thickness_bias_mm": 0.010,
          "highlight_rules": [
            // Split matching pads into a dedicated colored STEP body
            { "designators": ["TP*"], "color": "red", "step_body_name": "test_points" }
          ]
        },
        "free_pads": { "enabled": false, "color": "#B87333", "step_body_name": "free_pads", "thickness_bias_mm": 0.010 },
        "tracks":    { "enabled": false, "color": "#B87333", "step_body_name": "tracks",    "thickness_bias_mm": 0.0 },
        "arcs":      { "enabled": false, "color": "#B87333", "step_body_name": "arcs",      "thickness_bias_mm": 0.0 },
        "fills":     { "enabled": false, "color": "#B87333", "step_body_name": "fills",     "thickness_bias_mm": 0.0 },
        "polygons":  { "enabled": false, "color": "#7A8F2A", "step_body_name": "polygons",  "thickness_bias_mm": 0.003 },
        "regions":   { "enabled": false, "color": "#7A8F2A", "step_body_name": "regions",   "thickness_bias_mm": 0.003 },
        "vias":      { "enabled": false, "color": "#C08540", "step_body_name": "vias",      "thickness_bias_mm": 0.006 }
      },
      "drills": {
        "mode": "overlay",                  // "auto" | "cut" | "overlay" | "none"
        "selected_component_mode": "cut",   // "inherit" | "cut" | "overlay" | "none"
        "other_component_mode": "none",
        "free_pad_mode": "overlay",
        "via_mode": "inherit",
        "minimum_diameter_mm": 0.85,        // Skip holes smaller than this diameter
        "shape": "ring",                    // "solid" | "ring"
        "color": "#666666",
        "plated_color": "#666666",
        "non_plated_color": "#00AEEF",
        "ring_width_mm": 0.12,
        "plated_ring_shape": "pad",         // "annulus" | "pad"
        "overlay_thickness_mm": 0.001
      },
      "fuse_copper": false
    }
  ]
}

Precedence & Conflict Rules

  1. Five-level option merge ladder (lowest to highest):
    1. Root-level flat fields (any key outside defaults and outputs).
    2. defaults block.
    3. Per-output entry outputs[i].
    4. Nested options sub-object inside a config block (if present).
    5. Explicit CLI flags (applied to every output entry in outputs[]).
  2. --no-hole-cuts overrides --drill-hole-mode:
    • Passing --no-hole-cuts forces drills.mode = "none" and disables all drill-hole cutting/overlays, completely winning over --drill-hole-mode and any drills.* config setting.
  3. Drill color cascade (highest wins):
    1. Specific CLI split flag (--drill-plated-hole-color / --drill-non-plated-hole-color).
    2. Generic CLI --drill-hole-color — note that setting --drill-hole-color overrides BOTH split drills.plated_color and drills.non_plated_color from the config file!
    3. Config split colors (drills.plated_color, drills.non_plated_color).
    4. Config fallback (drills.color).
  4. Zero-geometry conflict (--outline-only + --no-board-outline):
    • --outline-only disables all copper features (features.*); --no-board-outline forces include_board_outline = false. Combining them leaves nothing to extrude and fails with a geometry error unless board cutouts or drill overlays remain active.
  5. --no-fuse disables BOTH fusion flags:
    • Passing --no-fuse forces both fuse_copper = false and board_outline.fuse = false, preserving primitive-level regions.
  6. Removed v1 config keys fail fast:
    • Legacy v1 fields are rejected with explicit migration errors:
      • Root fields: colors, pad_color_rules, pad_rules, thickness_bias, thickness_bias_mm.
      • Feature/rule fields: features.<name>.body and features.component_pads.highlight_rules[].body (renamed to step_body_name).
  7. Layer selector aliases:
    • --layer / layer accepts top/F.Cu/0, bottom/B.Cu/31, inner copper ordinals 1..30 (In1.Cu..In30.Cu), or canonical KiCad layer names (Edge.Cuts, F.SilkS, etc.).

Quick Examples

sh
# Export a top-copper Micro-STEP alignment model
kcr pcb-layer-step board.kicad_pcb --layer F.Cu -o output/step
sh
# Export a bottom-copper alignment model with custom thickness
kcr pcb-layer-step board.kicad_pcb --layer B.Cu --thickness-mm 0.035 -o output/step
kicad-monkey v2026.11.30·Docs updated 2026.12.01 15:43 UTC (fd9b75b)