kicad monkey v2026.11.30
On This Page (10)

kcr pnp

Generate Pick-and-Place (PnP) from KiCad .kicad_pro or .kicad_pcb files. Includes all component parameters. Config-driven runs can emit JSON, CSV, XLSX, and JLCPCB CPL upload columns in one invocation. Config output_fields can include generated placement fields such as center_x, center_y, rotation, and units, canonical fields such as manufacturer or mpn, and exact raw KiCad parameter names.

CommandAliasesCategoryRuntimeConfigGuide
kcr pnp—Fabrication & Manufacturing OutputsPython kcr + Native Rust k3Optional ./bom.config in the current working directory (kicad_cruncher.bom.config.a0, never auto-created)Fabrication & Outputs

Usage

sh
kcr pnp [-h] [-o OUTPUT]
    [--format {csv,json,xlsx,jlc-cpl,jlc-cpl-xlsx}]
    [--config CONFIG] [--write-config [PATH]]
    [--variant VARIANT] [--all-variants]
    [--units {mm,mils}]
    [--position-mode {component-center}]
    [--exclude-no-bom] [--no-color]
    [file]

Native Rust CLI Equivalent (k3)

Implemented natively in k3 for CSV, JSON, and JLC CPL centroid exports (mm/mils and variants).

sh
k3 pnp [-o OUTPUT] [--format {csv,json,jlc-cpl}] [--units {mm,mils}] [--position-mode {component-center}] [--exclude-no-bom] [--config PATH] [--write-config [PATH]] [--variant NAME | --all-variants] [file]

Positional Arguments

ArgumentDescription
fileKiCad .kicad_pro or .kicad_pcb file (optional if one .kicad_pro in CWD)

Options

FlagDescription
-o, --output OUTPUTOutput directory (default: ./output/pnp)
--format FORMATSingle output format; overrides multi-output config mode. Choices: csv, json, xlsx, jlc-cpl, jlc-cpl-xlsx.
--config CONFIGBOM/PnP JSON/JSONC config (default: ./bom.config if present)
--write-config PATHWrite a documented JSONC BOM/PnP config template
--variant VARIANTFilter by specific variant name
--all-variantsGenerate PnP for all variants (plus base)
--units UNITSCoordinate units (default: config value or mm). Choices: mm, mils.
--position-mode POSITION_MODEPlacement position mode (default: config value or component-center). Choices: component-center.
--exclude-no-bomExclude placement-eligible parts that are not BOM-eligible
--no-colorDisable ANSI colors and animated spinners

How It Works

kcr pnp exports Pick-and-Place (centroid) placement tables from a KiCad project (.kicad_pro) or board (.kicad_pcb) relative to the board's aux axis / drill-place file origin, using the KiCad footprint placement point (component-center).

Like kcr bom, it supports both multi-artifact config mode and single-artifact legacy --format mode, sharing the exact same ./bom.config schema (kicad_cruncher.bom.config.a0).

Input & Config Discovery

  1. Input validation (no standalone schematics):
    • Accepts .kicad_pro or .kicad_pcb. Passing a .kicad_sch is rejected with exit code 1 because placement coordinates only exist on the PCB.
    • If omitted, auto-detects a single *.kicad_pro in CWD, falling back to a single *.kicad_pcb.
  2. Optional ./bom.config in CWD (never auto-created):
    • Explicit --config <path> loads that config file.
    • Otherwise, kcr pnp checks ./bom.config in the current working directory (not beside the board).
    • Unlike kcr bom, kcr pnp never auto-creates ./bom.config. If no config file is found, kcr pnp runs in legacy single-format mode (default --format csv, writing under ./output/pnp/).
    • When a config file is found and --format is omitted, kcr pnp runs in config mode: emitting every kind in pnp.outputs (default ["json", "csv"]) under ./output/{Command}/ and writing bom.config.used.json beside the outputs.
  3. --write-config [PATH]:
    • With no input file, writes the shared commented bom.config template and exits 0. With an input file, writes the template and proceeds with PnP export.

Configuration (pnp Section of bom.config)

See kcr bom Configuration for the full kicad_cruncher.bom.config.a0 schema (field_aliases, variants, output templates). The pnp section controls placement exports:

jsonc
{
  "schema": "kicad_cruncher.bom.config.a0",
  "pnp": {
    "outputs": ["json", "csv"],     // "json" | "csv" | "xlsx" | "jlc-cpl" | "jlc-cpl-xlsx"
    "output_fields": [
      "designator", "comment", "layer", "footprint",
      "center_x", "center_y", "rotation", "description"
    ],
    "units": "mm",                  // "mm" | "mils" (JLC CPL strictly requires "mm")
    "position_mode": "component-center",
    "exclude_no_bom": false,        // Omit parts marked exclude_from_bom
    "layer_order": ["top", "bottom"],
    "prefix_order": []              // Optional designator-prefix sort priority
  }
}

Precedence & Conflict Rules

  1. Hard error on JLC CPL with non-mm units:
    • If the effective units are not "mm" (from --units mils or pnp.units: "mils") and any requested output is jlc-cpl or jlc-cpl-xlsx (either via --format or via pnp.outputs in config mode), kcr pnp aborts immediately with exit code 1 because JLCPCB CPL strictly requires millimeters.
  2. DNP parts are ALWAYS excluded:
    • Any component marked DNP (from schematic DNP state, footprint dnp attribute, or active variant override) is unconditionally omitted from PnP and CPL outputs, regardless of bom.include_dnp or --exclude-no-bom.
  3. --exclude-no-bom is OR-only:
    • Effective exclude_no_bom = cli.--exclude-no-bom OR config.pnp.exclude_no_bom. You can enable it on the CLI over false in bom.config, but you cannot disable pnp.exclude_no_bom: true via a CLI flag.
  4. Units & position mode precedence:
    • CLI --units overrides pnp.units (default "mm").
    • CLI --position-mode overrides pnp.position_mode (default "component-center").
  5. Config mode vs --format mode:
    • Passing --format overrides pnp.outputs, writes one file to ./output/pnp/<stem>[_<variant>]_pnp.<ext>, and skips bom.config.used.json.
  6. Variant selection:
    • Follows the shared ladder: --all-variants > --variant <NAME> > variants.* in bom.config. Unknown variant names warn rather than fail.
  7. Python kcr vs native Rust k3:
    • Native Rust k3 pnp emits csv, json, and jlc-cpl; Python kcr pnp additionally emits formatted .xlsx workbooks (xlsx, jlc-cpl-xlsx).

Quick Examples

sh
# Export Pick-and-Place CSV from a board or project
kcr pnp board.kicad_pcb -o output/pnp
sh
# Export PnP in mils for a named variant, excluding No-BOM parts
kcr pnp project.kicad_pro --units mils --exclude-no-bom --variant Proto -o output/pnp
kicad-monkey v2026.11.30·Docs updated 2026.12.01 15:43 UTC (fd9b75b)