main
John Lauer
Record finer-grid current failure and preserve unaccepted source-taper experiment
bcfbe47
"""Native KiCad 10 candidate from board-17. Copy matching project sidecars FIRST.
Run on the desktop with KiCad Python; does not grant acceptance.
"""
from pathlib import Path
import pcbnew,json,shutil
p=Path(__file__).parent
source=p/'via-qualified.kicad_pcb';target=p/'source-taper.kicad_pcb'
for ext in ['kicad_pro','kicad_dru']:
shutil.copyfile(source.with_suffix('.'+ext),target.with_suffix('.'+ext))
m=pcbnew.GetSettingsManager();project=str(target.with_suffix('.kicad_pro'))
assert m.LoadProject(project)
b=pcbnew.LoadBoard(str(source));b.SetProject(m.GetProject(project))
points=[(123.7,80.8),(125.9,80.8),(125.9,83.2),(126.4,83.4),(133.8,83.4),(135.4,84.7),(138,84.7),(138,88),(134.5,88),(133.5,85.2),(126,85.2),(123.7,83.6)]
zones=list(b.Zones());changed=[]
for z in zones:
if z.m_Uuid.AsString()=='e0cd80c3-561d-4fab-b292-e46839ad4bed':
z.Outline().RemoveAllContours();z.Outline().NewOutline()
for x,y in points:z.Outline().Append(pcbnew.FromMM(x),pcbnew.FromMM(y))
changed.append(z.m_Uuid.AsString())
tracks=list(b.GetTracks());removed=[]
for t in tracks:
if t.m_Uuid.AsString()=='3b6462fa-fe3c-450b-b89f-ad9d10469424':
removed.append(t.m_Uuid.AsString());b.Remove(t)
assert len(changed)==1 and len(removed)==1
pcbnew.SaveBoard(str(target),b)
# Re-read after removing a SWIG item before traversing zone wrappers.
b2=pcbnew.LoadBoard(str(target));b2.SetProject(m.GetProject(project))
pcbnew.ZONE_FILLER(b2).Fill(b2.Zones());pcbnew.SaveBoard(str(target),b2)
print(json.dumps({'changedZones':changed,'removedTracks':removed,'candidate':str(target),'acceptance':'Native DRC plus full-spec Fields required; diagnostic-only solves cannot qualify this candidate.'}))