main
John Lauer Preserve board29, component assets and scaffold-fit correction candidate with reviewed footage c54169e
"""Isolated D1 placement/power-routing experiment. Never edits the live board."""
import pcbnew as k, json, shutil
from pathlib import Path
p=Path(__file__).parent;b=k.LoadBoard(str(p/'source.kicad_pcb'));removed=[]
f=next(f for f in b.GetFootprints()if f.GetReference()=='D1');old=f.GetOrientationDegrees();f.SetOrientationDegrees((old+180)%360)
for t in list(b.GetTracks()):
 net=t.GetNetname()
 remove=net=='DUT_FUSED' or (net=='LOAD_POS' and ((isinstance(t,k.PCB_VIA)and k.ToMM(t.GetPosition().x)<120)or(not isinstance(t,k.PCB_VIA)and k.ToMM(t.GetWidth())>=1.19)))
 if remove:removed.append(t.m_Uuid.AsString());b.Remove(t)
k.ZONE_FILLER(b).Fill(b.Zones());k.SaveBoard(str(p/'candidate.kicad_pcb'),b)
for ext in ['kicad_pro','kicad_dru']:shutil.copy2(p/('source.'+ext),p/('candidate.'+ext))
(p/'orientation-review.json').write_text(json.dumps({'reference':'D1','oldDegrees':old,'newDegrees':f.GetOrientationDegrees(),'removedItems':removed,'status':'unrouted-isolated-experiment'},indent=2))
print('Isolated D1 orientation candidate; removed',len(removed),'power items for reroute.')