← Documentation index

PPEXTRACT_SOURCES

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXIT STATUS
EXAMPLES
SEE ALSO

NAME

ppextract_sources - write a sources file for ppresolve_components from a schematic’s own embedded symbols

SYNOPSIS

ppextract_sources [-o FILE] [--symbol-dir DIR] [--portable] [--kicad-cli CMD] [--quiet] SCHEMATIC
ppextract_sources
{--help|--version}

DESCRIPTION

ppextract_sources reads a KiCad schematic (a .kicad_sch file, with the sheets it includes) and writes two things: the symbols the schematic embeds (its own copy of every symbol it uses, exactly as its author drew it), one .kicad_sym file per library nickname, into a directory; and a sources file for ppresolve_components(1) with one entry per part, whose sym_path points at those files.

Those paths are absolute, the machine’s own. With --portable the files that are under KiCad’s symbol directory are written with a KiCad variable, ${KICAD_SYM_DIR}/Device.kicad_sym, and those under a component library directory as paths relative to it (see ppresolve_components(1)); a portable form is written only if it names the very same file on this machine.

It exists for the build-instructions route, where ppresolve_components(1) needs to be told which KiCad symbol each reference is. A design that predates a library rename keeps the old symbol name only in its own embedded symbols: KiCad 10’s installed Connector library no longer has Conn_01x03_Male, for instance, so pointing a sources entry at it ends in an error. The design’s own embedded symbol is the only one that exists, and reading it needs no library installed anywhere. Where both the schematic and an installed library (the directory named by $KICAD_SYM_DIR) have a symbol, the schematic’s own is used. A symbol that the schematic holds under a name of its own (KiCad writes a lib_name for a symbol that has drifted from its library, and gives the part no library in its netlist) gets an entry in a library called _embedded.

The pin_map is written empty. The build instructions give holes, not pins, so only you know which pin is which; see ppresolve_components(1). A part whose symbol is found neither in the schematic nor in an installed library is reported as a warning on standard error and is left out of the file, never given a path that cannot work.

OPTIONS

-o FILE, --output FILE

The sources file to write (default: STEM-sources.json, in the current directory, STEM being the schematic’s name without its extension).

--symbol-dir DIR

The directory the embedded libraries are written to (default: STEM-symbols in the directory of the sources file, which is the current directory when -o is not given; before 0.72.59 it was always the current directory). The paths in the sources file are absolute, unless --portable says otherwise.

--portable

Write the library files that are under KiCad’s symbol directory (${KICAD_SYM_DIR}, or /usr/share/kicad/symbols) as ${KICAD_SYM_DIR}/NAME.kicad_sym, and those under a component library directory ($PACKPAY_COMPONENT_LIBS) as paths relative to it, so that the sources file can be used on another machine, where ppresolve_components(1) resolves them. The file of an embedded library (under --symbol-dir) is replaced by the library of the same name in one of those places when that library has the part and draws it the same (the same pins, names, types and positions); the others stay absolute. A portable form is written only if it names the very same file here.

--kicad-cli CMD

The kicad-cli command used to read the schematic’s netlist (default: $KICAD_CLI if set, else kicad-cli).

--quiet

Suppress the informational messages; warnings are still printed.

EXIT STATUS

0 on success, also when some parts could not be given an entry (a warning is printed for each). 1 if the input is not a .kicad_sch file (a netlist carries no symbols) or does not exist, or kicad-cli cannot be run or cannot read the schematic; one message is printed, never a traceback.

EXAMPLES

Write the sources file and the embedded libraries for a design, then fill in the pin map and resolve its build instructions:

ppextract_sources Camera-trap.kicad_sch
ppbuild_instructions Camera-trap.kicad_sch -o instructions.txt
# edit Camera-trap-sources.json: add the pin_map entries
ppresolve_components instructions.txt --sources Camera-trap-sources.json -o new.kicad_sch

SEE ALSO

ppresolve_components(1), ppbuild_instructions(1), ppkicad_layout(1), kicad-cli(1), ResearchJournal.org and SessionHandoff.org