skidl.tools.kicad8.sexp_schematic module¶
Shared S-expression schematic generation for KiCad 6/8/9.
Converts placed+routed SchNode trees into .kicad_sch files. Used by kicad6, kicad8, and kicad9 gen_schematic thin wrappers.
- Sources:
part_to_sexp / wire_to_sexp: upstream sexp_schematics branch (devbisme)
Hierarchy / custom fields / lib_symbols: feature/kicad8-gen-schematic (PR #281)
Net label logic: feature/inject-net-labels (PR #280)
Original kicad5 hierarchy walker: node_to_eeschema (kicad5/gen_schematic.py)
Credit: cyberhuman (PR #270) for initial KiCad 8 schematic work
- skidl.tools.kicad8.sexp_schematic.node_to_sexp_schematic(node, sheet_tx=Tx(), version=20230409)[source]¶
Convert a SchNode tree to S-expression schematic(s).
Follows the same recursive pattern as kicad5’s node_to_eeschema(): - Flattened nodes: return elements for inclusion in the parent sheet. - Unflattened nodes: write a separate .kicad_sch file and return a
sheet reference for the parent.
- Parameters:
node – SchNode to convert.
sheet_tx – Parent sheet transformation matrix.
version – S-expression version number (20240108 for kicad6, 20230409 for kicad8/9).
- Returns:
S-expression elements (parts, wires, labels, or a sheet ref).
- Return type:
list[Sexp]
- skidl.tools.kicad8.sexp_schematic.write_top_schematic(circuit, node, filepath, top_name, title, version=20230409)[source]¶
Generate and write the complete schematic from a placed+routed node tree.
This is the main entry point called by each tool’s gen_schematic().
- Parameters:
circuit – The Circuit object.
node – Root SchNode (placed and routed).
filepath – Output directory.
top_name – Base filename (without extension).
title – Schematic title.
version – S-expression version number.
