feat(schematic): reposition and auto-place Ref/Value field labels

Adds field-placement tools:
- set_schematic_property_position / batch_set_schematic_property_positions:
  move a symbol's Reference/Value field labels
- autoplace_schematic_fields: place every symbol's fields clear of its body
  and nearby net labels (the #1 readability problem in generated schematics)
- check_schematic_layout: audit out-of-bounds / fields-in-body / duplicate
  labels (note: overlaps upstream find_overlapping_elements etc. — reuse or
  drop on request)

Generic .kicad_sch text helpers are factored into commands/schematic_text_utils.py
so the batch/hierarchy modules don't import from one another.

- python/commands/schematic_text_utils.py: shared text/S-expr helpers
- python/commands/schematic_field_layout.py: SchematicFieldLayoutCommands
- src/tools/schematic-layout.ts + registry 'schematic_layout' category
- python/kicad_interface.py: import + instantiate + dispatch routes
- tests/test_schematic_field_layout.py: 23 unit tests incl. end-to-end on real .kicad_sch

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ravi
2026-06-02 19:38:54 -07:00
committed by mixelpixx
parent 2dcfc0f4c2
commit 7c385b993f
7 changed files with 1073 additions and 0 deletions

View File

@@ -326,6 +326,7 @@ try:
from commands.routing import RoutingCommands
from commands.schematic import SchematicManager
from commands.schematic_hierarchy import SchematicHierarchyCommands
from commands.schematic_field_layout import SchematicFieldLayoutCommands
from commands.symbol_creator import SymbolCreator
from commands.symbol_pins import SymbolPinCommands
@@ -450,6 +451,8 @@ class KiCADInterface:
self.symbol_pin_commands = SymbolPinCommands()
# Schematic hierarchy commands (insert sheets, scaffold sub-sheets)
self.hierarchy_commands = SchematicHierarchyCommands(self)
# Schematic field placement / layout-check commands
self.field_layout_commands = SchematicFieldLayoutCommands()
# Initialize JLCPCB API integration
self.jlcpcb_client = JLCPCBClient() # Official API (requires auth)
@@ -540,6 +543,10 @@ class KiCADInterface:
# Schematic hierarchy commands (sheet insertion + subsheet scaffolding)
"add_hierarchical_sheet": self.hierarchy_commands.add_hierarchical_sheet,
"create_hierarchical_subsheet": self.hierarchy_commands.create_hierarchical_subsheet,
# Schematic field placement commands
"set_schematic_property_position": self.field_layout_commands.set_schematic_property_position,
"batch_set_schematic_property_positions": self.field_layout_commands.batch_set_schematic_property_positions,
"autoplace_schematic_fields": self.field_layout_commands.autoplace_schematic_fields,
# JLCPCB API commands (complete parts catalog via API)
"download_jlcpcb_database": self._handle_download_jlcpcb_database,
"search_jlcpcb_parts": self._handle_search_jlcpcb_parts,