skill
EDA Skillpack
Public Made by Adomby adom
All skills for all EDA capabilities across the Adom ecosystem.
main
from pathlib import Path
import json
from fixture_geometry import parse,Node,apply_edits,at_edit,normalize_deg
D=Path(__file__).parent
s=(D/'esc-g431-astra-independent.kicad_pcb').read_text();r=parse(s)
p=json.loads((D/'evidence/fresh-plan.json').read_text());by={v['ref']:v for v in p};by['R32']['rotation']=270
edits=[]
for f in r.find_all('footprint'):
ref=next(p.atom(2) for p in f.find_all('property') if p.value()=='Reference')
if ref not in by:continue
p=by[ref];at=f.find('at');old=at.number(3) or 0;new=p['rotation'];edits.append(at_edit(at,p['x'],p['y'],new,True))
for c in f.items:
if isinstance(c,Node) and c.tag in ['pad','property','fp_text']:
a=c.find('at')
if a:edits.append(at_edit(a,a.number(1),a.number(2),normalize_deg((a.number(3) or 0)-old+new),True))
(D/'route-input.kicad_pcb').write_text(apply_edits(s,edits))