from pathlib import Path
import json,wx
_app=wx.App(False)
import pcbnew as k
p=Path(__file__).resolve().parent;d=p/'board';b=k.LoadBoard(str(d/'led_driver.kicad_pcb'));paths=json.loads((p/'mounting_paths.json').read_text())
for f in b.GetFootprints():
 if f.GetReference() in paths['holes']:
  f.SetFPID(k.LIB_ID('Lamp_Driver','MountingHole_3.2mm_M3'));f.SetValue('M3_mount');f.SetPath(k.KIID_PATH('/'+paths['root']+'/'+paths['holes'][f.GetReference()]));f.SetAttributes(f.GetAttributes()|k.FP_EXCLUDE_FROM_BOM)
k.SaveBoard(str(d/'led_driver.kicad_pcb'),b)
assert k.ExportSpecctraDSN(b,str(p/'routing_input.dsn'))
print('Updated4 mechanical paths and exported DSN')
