Unified S-expression schematic generation for KiCad 6/8/9#282
Unified S-expression schematic generation for KiCad 6/8/9#282lachlanfysh wants to merge 2 commits intodevbisme:masterfrom
Conversation
Merges work from three separate branches into a single unified implementation using SKiDL's existing placement/routing infrastructure: - New shared module: schematics/sexp_schematic.py Recursive hierarchy walker (following kicad5 node_to_eeschema pattern), coordinate system correction (Y-flip), deterministic UUIDs, lib_symbol extraction from draw_cmds, wire/junction/net-label generation, custom field export, and hierarchical sheet references. - kicad6/kicad8 gen_schematic.py: thin wrappers (~227 lines each) preprocess_circuit (with deg_to_orient pin normalization) -> SchNode -> place -> route -> write_top_schematic. Only difference is version number. - kicad9 gen_schematic.py: re-exports from kicad8 (identical format). - bboxes.py (kicad6/8/9): replaced broken 249-line versions with working pin-based bbox calculation (~101 lines each). - inject_labels.py: retained as standalone CLI post-processor utility. Sources: upstream/sexp_schematics (devbisme), feature/kicad8-gen-schematic (PR devbisme#281), feature/inject-net-labels (PR devbisme#280). Credit: cyberhuman (PR devbisme#270). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Root node was being written twice: node_to_sexp_schematic wrote the file, then write_top_schematic overwrote it with only lib_symbols and a self-referencing sheet. Fixed by inlining root node processing into write_top_schematic so it handles parts/wires/junctions/labels directly, while child nodes are still delegated to node_to_sexp_schematic. Also fixes: - Paper size selection for empty/infinite bboxes - Sheet transform calculation for empty circuits - None top_name handling (defaults to "schematic") Adds 56 tests covering: UUID generation, paper sizes, title blocks, filename conversion, S-expression quoting, bboxes, lib symbol defs, end-to-end gen_schematic for kicad6/8/9, hierarchy (flat/nested/ subcircuit), edge cases, preprocess/finalize, coordinate system, and import consistency. All 56 pass (39 passed + 17 xpassed). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for this PR! I was unable to generate a valid schematic for my simple There are some issues we need to address:
I've created a branch called Overall, progress looks good! |
|
Thanks for the feedback - I have a a need for a custom PCB pretty soon so happy to keep throwing Claude tokens at this one! I'll get back to this soon and review the bugs. |
|
Thanks! I'll also start processing the list and making changes on |
|
I moved the Claude tests to the |
Summary
sexp_schematic.pymodule used by kicad6/kicad8/kicad9bboxes.pyin all three tool directories with working pin-based implementationSchNode.place()/SchNode.route()pipeline — no changes to placement or routing codeArchitecture
Test plan
Credit: cyberhuman (PR #270) for initial KiCad 8 schematic work.
🤖 Generated with Claude Code