main
John Lauer
Track overnight board completion, native DFT repair and viewer performance evidence
d5a0db3
from pathlib import Path
import sys,copy,uuid,math,shutil
from shapely.geometry import Point,LineString
from shapely.ops import unary_union
import sexp
R=Path(__file__).resolve().parents[1];D=R/'probing-flow/design-candidate';b=sexp.parse((D/'sidefan-dft-r4.kicad_pcb').read_text());S=sexp.Sym
# Remove one native-reported dead-end 3V3 stub; renewed connectivity check required.
b[:]=[v for v in b if not(isinstance(v,list)and sexp.first(v,'uuid')==['uuid','f7904a8b-fcc5-4ae6-bf0b-ff7b8ba843ee'])]
# Clip obsolete medium-pin outline graphics outside the enlarged corner contact markings.
keep=[];mask=unary_union([Point(100,100).buffer(3.5),Point(164,100).buffer(3.5)])
for v in b:
if isinstance(v,list)and v[0]=='gr_line'and sexp.first(v,'layer')[1]in ['F.SilkS','B.SilkS']:
a=list(map(float,sexp.first(v,'start')[1:3]));c=list(map(float,sexp.first(v,'end')[1:3]));line=LineString([a,c]);clipped=line.difference(mask)
if clipped.equals(line):keep.append(v);continue
for seg in ([clipped]if clipped.geom_type=='LineString'else getattr(clipped,'geoms',[])):
if seg.length<.25:continue
n=copy.deepcopy(v);sexp.first(n,'start')[1:3]=list(seg.coords[0]);sexp.first(n,'end')[1:3]=list(seg.coords[-1]);sexp.first(n,'uuid')[1]=str(uuid.uuid4());keep.append(n)
else:keep.append(v)
b=keep
# Explicit reference relocation; all labels preserved, no hidden silkscreen exemptions.
xy={'TP3':(98.2,84.7),'TP7':(98.2,90.3),'TP9':(105.8,85.2),'TP14':(122.4,102.4),'TP16':(146.4,101.9),'J8':(164.2,48.0)}
for f in sexp.find(b,'footprint'):
ref=next(p[2]for p in sexp.find(f,'property')if p[1]=='Reference')
if ref not in xy:continue
a=sexp.first(f,'at');x,y=map(float,a[1:3]);ang=math.radians(float(a[3])if len(a)>3 else 0);dx,dy=xy[ref][0]-x,xy[ref][1]-y
prop=next(p for p in sexp.find(f,'property')if p[1]=='Reference');sexp.first(prop,'at')[1:3]=[dx*math.cos(ang)-dy*math.sin(ang),dx*math.sin(ang)+dy*math.cos(ang)]
for v in sexp.find(b,'gr_text'):
if v[1]=='GND' and float(sexp.first(v,'at')[1])<103 and float(sexp.first(v,'at')[2])>96:sexp.first(v,'at')[1:3]=[100,95.2]
(D/'sidefan-dft-r5.kicad_pcb').write_text(sexp.dump(b)+'\n')
for ext in ['kicad_pro','kicad_dru']:shutil.copy2(D/f'sidefan-dft-r4.{ext}',D/f'sidefan-dft-r5.{ext}')