On This Page (7)
kcr project-lib
Extract symbols, footprints, metadata, and embedded STEP models from a KiCad project into metadata-preserving project-local library artifacts.
| Command | Aliases | Category | Runtime | Config | Guide |
|---|---|---|---|---|---|
kcr project-lib | kcr project-library, kcr project-local-lib, kcr local-library | Projects, Libraries & Assets | Python kcr | None (CLI flags only) | Projects, Variants & Design |
Usage
kcr project-lib [-h] [-o OUTPUT]
[--symbol-library-dir SYMBOL_LIBRARY_DIR]
[--footprint-library-dir FOOTPRINT_LIBRARY_DIR]
[--symbol-library-name SYMBOL_LIBRARY_NAME]
[--footprint-library-name FOOTPRINT_LIBRARY_NAME]
[--include-models] [--embed-board-models]
[--no-update-library-tables]
[--relink-dry-run | --relink-sources]
[--repair-cache-links] [--no-embed-models]
[--no-embed-external-models]
[--all-embedded-models]
[--include-asset-scan]
[--validate-kicad-cli]
[--kicad-cli KICAD_CLI]
[file]Positional Arguments
| Argument | Description |
|---|---|
file | KiCad .kicad_pro project; optional when one .kicad_pro is in CWD |
Options
| Flag | Description |
|---|---|
-o, --output OUTPUT | Output directory (default: ./local-library) |
--symbol-library-dir SYMBOL_LIBRARY_DIR | Symbol library folder under the output directory (default: .kicad_pro stem) |
--footprint-library-dir FOOTPRINT_LIBRARY_DIR | Footprint .pretty folder under the output directory (default: <.kicad_pro stem>.pretty) |
--symbol-library-name SYMBOL_LIBRARY_NAME | Symbol library nickname to add to sym-lib-table (default: symbol folder name) |
--footprint-library-name FOOTPRINT_LIBRARY_NAME | Footprint library nickname to add to fp-lib-table (default: .pretty folder stem) |
--include-models | Write decoded embedded STEP/STP model files into models/ |
--embed-board-models | After extraction, embed resolved external STEP models natively into the project .kicad_pcb at deduplicated board scope (dry-run when --relink-dry-run is set) |
--no-update-library-tables | Extract artifacts without editing project sym-lib-table/fp-lib-table |
--relink-dry-run | Write a source_relink.json plan without editing schematic or PCB files. Mutually exclusive with --relink-sources. |
--relink-sources | Rewrite source schematic and PCB references to the generated local libraries. Mutually exclusive with --relink-dry-run. |
--repair-cache-links | With relink dry-run/apply, repair placed schematic lib_name aliases when exactly one embedded cache symbol matches by member name |
--no-embed-models | Do not copy board-level embedded model payloads into extracted footprints |
--no-embed-external-models | Do not embed resolvable external STEP/STP model references into extracted footprints |
--all-embedded-models | Scan the full project and write every embedded STEP/STP payload to models/ |
--include-asset-scan | Include full project asset/model scan in library_extraction.json |
--validate-kicad-cli | Validate generated libraries with kicad-cli; project-lib apply mode also runs a before/after schematic ERC library-hygiene gate |
--kicad-cli KICAD_CLI | Explicit kicad-cli executable for --validate-kicad-cli |
How It Works
kcr project-lib (aliases project-library, project-local-lib, local-library) extracts all symbols, footprints, metadata, and embedded 3D STEP models used by a .kicad_pro into a metadata-preserving project-local library under -o <dir> (default ./local-library — not ./output/project-lib).
By default, it writes:
<output>/<stem>/— project-local symbol library (customize via--symbol-library-dir/--symbol-library-name).<output>/<stem>.pretty/— project-local footprints with board-level and external STEP models embedded into each.kicad_mod(customize via--footprint-library-dir/--footprint-library-name; suppress model embedding via--no-embed-models/--no-embed-external-models).project_lib_manifest.json(kicad_cruncher.project_lib_manifest.a0),library_extraction.json, andREADME.md.- Updates project-local
sym-lib-tableandfp-lib-table(unless--no-update-library-tablesis passed). - Optionally writes
source_relink.json(--relink-dry-run) or rewrites schematic/PCB library links in place (--relink-sources), and optionally embeds resolved external STEP models directly into the project.kicad_pcb(--embed-board-models).
Conflict & Flag Interaction Rules
--relink-dry-runvs--relink-sources(mutually exclusive):--relink-dry-runcomputes and writessource_relink.jsonwithout editing any.kicad_schor.kicad_pcbfile.--relink-sourcesrewrites schematic and PCB symbol/footprint references to point at the newly extracted project-local libraries.
--relink-sources+--no-update-library-tables-> exit code2:- Hard error! Relinking schematics and PCBs to new local library nicknames without registering those nicknames in
sym-lib-table/fp-lib-tablewould break KiCad resolution. Remove--no-update-library-tablesor switch to--relink-dry-run.
- Hard error! Relinking schematics and PCBs to new local library nicknames without registering those nicknames in
--repair-cache-linksrequires a relink flag -> exit code2:- Passing
--repair-cache-linkswithout either--relink-dry-runor--relink-sourcesfails immediately with exit code2.
- Passing
--embed-board-modelsinherits dry-run state from--relink-dry-run:- When
--embed-board-modelsis set alongside--relink-dry-run, board STEP embedding also runs in dry-run mode (no.kicad_pcbwrite). Without--relink-dry-run, it runsembed-modelsin apply mode (subject to KiCad.lcklock checks) using<output>/modelsas an extra search directory when present.
- When
--include-modelsvs--all-embedded-models:- By default, decoded STEP files are embedded inside extracted
.kicad_modfootprints without writing loose.stepfiles tomodels/. Passing--include-modelsor--all-embedded-modelswrites decoded STEP/STP files into<output>/models/.
- By default, decoded STEP files are embedded inside extracted
--validate-kicad-cli:- Runs
kicad-clilibrary validation against the generated libraries (and in--relink-sourcesapply mode, runs a before/after schematic ERC library-hygiene gate). Any validation failure returns exit code1even though artifacts were written.
- Runs
Quick Examples
# Preview source relinking without modifying project files
kcr project-lib project.kicad_pro --relink-dry-run# Extract project-local libraries with embedded STEP models and relink references
kcr project-lib project.kicad_pro --relink-sources# Also embed resolved external STEP models directly into the project's .kicad_pcb
kcr project-lib project.kicad_pro --relink-sources --embed-board-models