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.
| Command | Aliases | Category | Runtime | Config | Guide |
|---|---|---|---|---|---|
kcr pcb-layer-step | — | Fabrication & Manufacturing Outputs | Python 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
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.
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
| Argument | Description |
|---|---|
file | KiCad project or PCB file (optional if auto-detected in CWD) |
Options
| Flag | Description |
|---|---|
-o, --output OUTPUT | Output directory (default: ./output/pcb-layer-step) |
--config CONFIG | Path 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-config | Write a pcb-layer-step JSONC config template and exit without loading PCB data |
--force-config | With --init-config, overwrite an existing config template |
--doc, --pcbdoc PCBDOC | With .kicad_pro input, select a specific .kicad_pcb by filename, stem, or relative path |
--layer LAYER | PCB layer selector: bottom, top, B.Cu, F.Cu, layer id, or layer name |
--thickness-mm THICKNESS_MM | Extruded layer thickness in millimeters (default: 0.035) |
--z-mm Z_MM | Bottom Z position in millimeters (default: 0) |
--copper-color COPPER_COLOR | STEP color for selected-layer copper, #RRGGBB or name (default: #B87333) |
--outline-width-mm OUTLINE_WIDTH_MM | Board-outline body width in millimeters (default: 0.2) |
--outline-color OUTLINE_COLOR | STEP color for board outline, #RRGGBB or name (default: #FFFF00) |
--board-cutout-color BOARD_CUTOUT_COLOR | STEP color for interior board-cutout outline bodies (default: #FFFF00) |
--exclude-poured-polygons | Exclude poured-zone geometry from the selected layer |
--outline-only | Emit only the board outline body |
--no-board-outline | Do not include the board-outline body |
--no-board-cutouts | Do not include separate interior board-cutout outline bodies |
--no-hole-cuts | Do not subtract or overlay pad/via drill holes in copper geometry |
--drill-hole-mode DRILL_HOLE_MODE | Drill-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_CUTS | Auto mode uses boolean drill cuts up to this count (default: 128) |
--drill-hole-color DRILL_HOLE_COLOR | STEP color for drill overlays, #RRGGBB or name (default: #FFFFFF) |
--drill-plated-hole-color DRILL_PLATED_HOLE_COLOR | STEP color for plated drill overlays when plating colors are split |
--drill-non-plated-hole-color DRILL_NON_PLATED_HOLE_COLOR | STEP color for non-plated drill overlays when plating colors are split |
--drill-overlay-thickness-mm DRILL_OVERLAY_THICKNESS_MM | Thickness for fast drill-overlay bodies in millimeters (default: 0.001) |
--drill-minimum-diameter-mm DRILL_MINIMUM_DIAMETER_MM | Only render drills larger than this diameter in millimeters |
--drill-hole-shape DRILL_HOLE_SHAPE | Overlay drill shape: solid disk/capsule or annular ring. Choices: solid, ring. |
--drill-ring-width-mm DRILL_RING_WIDTH_MM | Annular ring width when --drill-hole-shape ring is active |
--drill-plated-ring-shape DRILL_PLATED_RING_SHAPE | Plated drill ring source: fixed annulus or full pad shape. Choices: annulus, pad. |
--no-fuse | Preserve primitive-level copper and board-outline regions instead of requesting 2D copper fusion |
--arc-segments ARC_SEGMENTS | Fallback sampling resolution for elliptical pads and slots (default: 32) |
--no-color | Disable 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:
- Exact analytic curves (
CIRCLE,CYLINDRICAL_SURFACE) for round pads, vias, holes, annuli, obrounds, and arcs. - Assembly instancing (
NEXT_ASSEMBLY_USAGE_OCCURRENCE+ITEM_DEFINED_TRANSFORMATION) so repeated identical pads and drills share one geometric definition. - Board aux-axis coordinates: XY geometry is shifted relative to the KiCad
aux_axis_originwhen present, or absolute KiCad millimeters otherwise. - Symmetric Z bias (
thickness_bias_mm): prevents Z-fighting when colored bodies (e.g. redTP*test points, copper pads, and yellow board outline) overlap in mechanical CAD viewers.
Input & Config Discovery
- Input resolution:
- Accepts
.kicad_pcbor.kicad_pro(use--doc <board>to pick one board in a multi-board project). - If omitted, auto-detects a single
*.kicad_proin CWD, falling back to a single*.kicad_pcb.
- Accepts
pcb-layer-step.jsoncdiscovery (always auto-creates when missing):--init-configwrites the commented template to--config <path>(or<input_dir>/pcb-layer-step.jsonc, or./pcb-layer-step.jsoncwhen no input is given) and exits without loading PCB data (--force-configoverwrites 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-steplooks for<input_dir>/pcb-layer-step.jsoncand auto-creates it if missing. Legacy.jsonfilenames 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[].
{
"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
- Five-level option merge ladder (lowest to highest):
- Root-level flat fields (any key outside
defaultsandoutputs). defaultsblock.- Per-output entry
outputs[i]. - Nested
optionssub-object inside a config block (if present). - Explicit CLI flags (applied to every output entry in
outputs[]).
- Root-level flat fields (any key outside
--no-hole-cutsoverrides--drill-hole-mode:- Passing
--no-hole-cutsforcesdrills.mode = "none"and disables all drill-hole cutting/overlays, completely winning over--drill-hole-modeand anydrills.*config setting.
- Passing
- Drill color cascade (highest wins):
- Specific CLI split flag (
--drill-plated-hole-color/--drill-non-plated-hole-color). - Generic CLI
--drill-hole-color— note that setting--drill-hole-coloroverrides BOTH splitdrills.plated_coloranddrills.non_plated_colorfrom the config file! - Config split colors (
drills.plated_color,drills.non_plated_color). - Config fallback (
drills.color).
- Specific CLI split flag (
- Zero-geometry conflict (
--outline-only+--no-board-outline):--outline-onlydisables all copper features (features.*);--no-board-outlineforcesinclude_board_outline = false. Combining them leaves nothing to extrude and fails with a geometry error unless board cutouts or drill overlays remain active.
--no-fusedisables BOTH fusion flags:- Passing
--no-fuseforces bothfuse_copper = falseandboard_outline.fuse = false, preserving primitive-level regions.
- Passing
- 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>.bodyandfeatures.component_pads.highlight_rules[].body(renamed tostep_body_name).
- Root fields:
- Legacy v1 fields are rejected with explicit migration errors:
- Layer selector aliases:
--layer/layeracceptstop/F.Cu/0,bottom/B.Cu/31, inner copper ordinals1..30(In1.Cu..In30.Cu), or canonical KiCad layer names (Edge.Cuts,F.SilkS, etc.).
Quick Examples
# Export a top-copper Micro-STEP alignment model
kcr pcb-layer-step board.kicad_pcb --layer F.Cu -o output/step# 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