main
John Lauer Publish review-only copper repair board with unchanged acceptance limits; current qualification remains open 9ad84f1
"""Run with native KiCad 10 Python, beside before.kicad_pcb. No local KiCad install."""
import pcbnew,json
from pathlib import Path
p=Path(__file__).parent;b=pcbnew.LoadBoard(str(p/'before.kicad_pcb'))
pts=[(123.7,80.8),(125.9,80.8),(126,82.8),(133.8,82.8),(135.4,84.7),(138,84.7),(138,88),(134.5,88),(133.5,85.2),(126,85.2),(123.7,83.6)]
changed=[]
for z in b.Zones():
 if z.GetNetname()=='SHUNT_P':
  z.SetLocalClearance(pcbnew.FromMM(.25))
  if z.Outline().Outline(0).PointCount()==9:
   z.Outline().RemoveAllContours();z.Outline().NewOutline()
   for x,y in pts:z.Outline().Append(pcbnew.FromMM(x),pcbnew.FromMM(y))
   changed.append(z.m_Uuid.AsString())
assert len(changed)==1
v=pcbnew.PCB_VIA(b);v.SetPosition(pcbnew.VECTOR2I(pcbnew.FromMM(134.8),pcbnew.FromMM(86)));v.SetWidth(pcbnew.FromMM(.6));v.SetDrill(pcbnew.FromMM(.3));v.SetLayerPair(pcbnew.F_Cu,pcbnew.B_Cu);v.SetViaType(pcbnew.VIATYPE_THROUGH);v.SetNet(b.FindNet('SHUNT_P'));b.Add(v)
pcbnew.ZONE_FILLER(b).Fill(b.Zones());removed=[]
for z in list(b.Zones()):
 if z.GetNetname()=='SHUNT_P' and z.GetFilledArea()==0:removed.append(z.m_Uuid.AsString());b.Remove(z)
pcbnew.ZONE_FILLER(b).Fill(b.Zones());pcbnew.SaveBoard(str(p/'reproduced.kicad_pcb'),b)
(p/'reproduced-evidence.json').write_text(json.dumps({'changedZones':changed,'removedEmptyZones':removed,'polygonMm':pts,'localClearanceMm':.25,'addedViaMm':[134.8,86],'nativeKiCad':pcbnew.GetBuildVersion(),'qualification':'Run DRC and same-input Fields before acceptance'},indent=2))