From 665511a995779ed209ab27de09d8a93e69e217f7 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 14:19:20 +0000 Subject: [PATCH] build_pcb: rip-up records copy coordinates (KiCad's vectors are views into the object) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013PRsUCpxazyipPn5UGGkF8 --- hardware/kicad/build_pcb.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hardware/kicad/build_pcb.py b/hardware/kicad/build_pcb.py index 8245ff5..d5e9965 100644 --- a/hardware/kicad/build_pcb.py +++ b/hardware/kicad/build_pcb.py @@ -1119,9 +1119,10 @@ def _connect(board, net, layers): def _track_record(t): """A track or via as plain values, enough to build it again.""" t = t.Cast() + xy = lambda p: (int(p.x), int(p.y)) # copies: KiCad's vectors are views into the object if t.Type() == pcbnew.PCB_VIA_T: - return ("via", t.GetPosition(), t.GetWidth(pcbnew.F_Cu), t.GetDrillValue(), t.GetNetCode()) - return ("track", t.GetStart(), t.GetEnd(), t.GetWidth(), t.GetLayer(), t.GetNetCode()) + return ("via", xy(t.GetPosition()), int(t.GetWidth(pcbnew.F_Cu)), int(t.GetDrillValue()), int(t.GetNetCode())) + return ("track", xy(t.GetStart()), xy(t.GetEnd()), int(t.GetWidth()), int(t.GetLayer()), int(t.GetNetCode())) def _track_rebuild(board, rec): @@ -1129,12 +1130,12 @@ def _track_rebuild(board, rec): if rec[0] == "via": _, pos, w, drill, net = rec v = pcbnew.PCB_VIA(board) - v.SetPosition(pos); v.SetWidth(w); v.SetDrill(drill); v.SetNetCode(net) + v.SetPosition(pcbnew.VECTOR2I(*pos)); v.SetWidth(w); v.SetDrill(drill); v.SetNetCode(net) board.Add(v) else: _, a, b, w, layer, net = rec t = pcbnew.PCB_TRACK(board) - t.SetStart(a); t.SetEnd(b); t.SetWidth(w); t.SetLayer(layer); t.SetNetCode(net) + t.SetStart(pcbnew.VECTOR2I(*a)); t.SetEnd(pcbnew.VECTOR2I(*b)); t.SetWidth(w); t.SetLayer(layer); t.SetNetCode(net) board.Add(t)