3 Commits

Author SHA1 Message Date
f797e9e070 Fix Y-axis inversion and label_connections save-order race condition
Two bugs in pin position resolution that caused incorrect schematic
coordinates and 28% label placement failures:

1. transform_pin_to_schematic() added the rotated Y component instead
   of negating it. lib_symbol pins use Y-up; schematics use Y-down.
   Fix: comp_y + ry -> comp_y - ry.

2. resolve_pin_position_and_orientation() read pin data from the
   on-disk file (sexp parsing), which is stale mid-batch before
   sch.save(). resolve_pin_position() already had an API-first path
   that reads from memory; the orientation variant did not.
   Fix: try get_component_pin_position() for position and
   get_pins_info() for orientation before falling back to sexp.

Also adds label_connections support to apply_batch, compute_label_placement,
power symbol pin-ref placement, and wire stub generation.
2026-03-06 17:08:57 -07:00
7525f3dcdc Fix add_label persistence and add_power_symbol custom library fallback
add_label bypasses kicad-sch-api serializer entirely — generates
s-expression strings and inserts them directly into the .kicad_sch
file via atomic write. Fixes two upstream bugs: global labels silently
dropped on save (serializer never iterates "global_label" key), and
local labels raising TypeError (parameter signature mismatch in
LabelCollection.add()).

add_power_symbol now falls back to sexp pin parsing when the API
returns None for custom library symbols (e.g. SMF5.0CA). Extracts
shared resolve_pin_position() utility used by both add_power_symbol
and batch operations.

Batch labels also fixed — collected as sexp strings during the batch
loop and inserted after sch.save() so the serializer can't overwrite
them.
2026-03-04 20:06:06 -07:00
ce65035a17 Add batch operations, power symbols, pattern templates, and schematic editing
New modules:
- patterns/ library: decoupling bank, pull resistor, crystal oscillator
  placement with power symbol attachment and grid math helpers
- tools/batch.py: atomic file-based batch operations with dry_run
- tools/power_symbols.py: add_power_symbol with auto #PWR refs
- tools/schematic_patterns.py: MCP wrappers for pattern library
- tools/schematic_edit.py: modify/remove components, title blocks, annotations
- resources/schematic.py: schematic data resources

43 new tests (99 total), lint clean.
2026-03-04 16:55:09 -07:00