From 6d5f2ac70270552ea614c5428e7684871144389f Mon Sep 17 00:00:00 2001 From: NicholasFaliszewski <111200985+NicholasFaliszewski@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:10:04 -0700 Subject: [PATCH] Updated plugin for KiCad 7 KiCad 7 seems to have changed some calls and broke the old implementation. These changes work for me on Ubuntu 20.04 --- coil_plugin.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/coil_plugin.py b/coil_plugin.py index 8eb2ecd..a9762cc 100644 --- a/coil_plugin.py +++ b/coil_plugin.py @@ -16,8 +16,8 @@ def create_tracks(board, group, net, layer, thickness, coords): y = coord["y"] + CENTER_Y track = pcbnew.PCB_TRACK(board) if last_x is not None: - track.SetStart(pcbnew.wxPointMM(float(last_x), float(last_y))) - track.SetEnd(pcbnew.wxPointMM(float(x), float(y))) + track.SetStart(pcbnew.VECTOR2I_MM(float(last_x), float(last_y))) + track.SetEnd(pcbnew.VECTOR2I_MM(float(x), float(y))) track.SetWidth(int(thickness * 1e6)) track.SetLayer(layer) if net is not None: @@ -89,7 +89,7 @@ class CoilPlugin(pcbnew.ActionPlugin): net = self.findNet(board, via) pcb_via = pcbnew.PCB_VIA(board) pcb_via.SetPosition( - pcbnew.wxPointMM(via["x"] + CENTER_X, via["y"] + CENTER_Y) + pcbnew.VECTOR2I_MM(via["x"] + CENTER_X, via["y"] + CENTER_Y) ) pcb_via.SetWidth(int(via_diameter * 1e6)) pcb_via.SetDrill(int(via_drill_diameter * 1e6)) @@ -102,7 +102,7 @@ class CoilPlugin(pcbnew.ActionPlugin): # x = pin["x"] + CENTER_X # y = pin["y"] + CENTER_Y # module = pcbnew.FOOTPRINT(board) - # module.SetPosition(pcbnew.wxPointMM(x, y)) + # module.SetPosition(pcbnew.VECTOR2I_MM(x, y)) # board.Add(module) # pcb_pad = pcbnew.PAD(module) # pcb_pad.SetSize(pcbnew.wxSizeMM(pin_diameter, pin_diameter)) @@ -110,7 +110,7 @@ class CoilPlugin(pcbnew.ActionPlugin): # pcb_pad.SetAttribute(pcbnew.PAD_ATTRIB_PTH) # pcb_pad.SetLayerSet(pcb_pad.PTHMask()) # pcb_pad.SetDrillSize(pcbnew.wxSizeMM(pin_drill, pin_drill)) - # pcb_pad.SetPosition(pcbnew.wxPointMM(x, y)) + # pcb_pad.SetPosition(pcbnew.VECTOR2I_MM(x, y)) # pcb_pad.SetNetCode(net.GetNetCode()) # module.Add(pcb_pad) @@ -122,7 +122,7 @@ class CoilPlugin(pcbnew.ActionPlugin): x = pin["x"] + CENTER_X y = pin["y"] + CENTER_Y module = pcbnew.FOOTPRINT(board) - module.SetPosition(pcbnew.wxPointMM(x, y)) + module.SetPosition(pcbnew.VECTOR2I_MM(x, y)) board.Add(module) pcb_pad = pcbnew.PAD(module) pcb_pad.SetSize(pcbnew.wxSizeMM(pin["width"], pin["height"])) @@ -130,9 +130,9 @@ class CoilPlugin(pcbnew.ActionPlugin): pcb_pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD) pcb_pad.SetLayerSet(pcb_pad.SMDMask()) # pcb_pad.SetLayerSet(lset) - pcb_pad.SetPosition(pcbnew.wxPointMM(x, y)) + pcb_pad.SetPosition(pcbnew.VECTOR2I_MM(x, y)) pcb_pad.SetNetCode(net.GetNetCode()) - pcb_pad.Flip(pcbnew.wxPointMM(x, y), False) + pcb_pad.Flip(pcbnew.VECTOR2I_MM(x, y), False) module.Add(pcb_pad) # create any silk screen @@ -141,9 +141,9 @@ class CoilPlugin(pcbnew.ActionPlugin): y = text["y"] + CENTER_Y pcb_txt = pcbnew.PCB_TEXT(board) pcb_txt.SetText(text["text"]) - pcb_txt.SetPosition(pcbnew.wxPointMM(x, y)) + pcb_txt.SetPosition(pcbnew.VECTOR2I_MM(x, y)) pcb_txt.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER) - pcb_txt.Rotate(pcbnew.wxPointMM(x, y), text["angle"]) + pcb_txt.Rotate(pcbnew.VECTOR2I_MM(x, y), text["angle"]) pcb_txt.SetTextSize( pcbnew.wxSize( text["size"] * pcbnew.IU_PER_MM, @@ -152,7 +152,7 @@ class CoilPlugin(pcbnew.ActionPlugin): ) pcb_txt.SetLayer(pcbnew.F_SilkS) if text["layer"] == "b": - pcb_txt.Flip(pcbnew.wxPointMM(x, y), True) + pcb_txt.Flip(pcbnew.VECTOR2I_MM(x, y), True) board.Add(pcb_txt) pcb_group.AddItem(pcb_txt) @@ -161,7 +161,7 @@ class CoilPlugin(pcbnew.ActionPlugin): # x = hole["x"] + CENTER_X # y = hole["y"] + CENTER_Y # module = pcbnew.FOOTPRINT(board) - # module.SetPosition(pcbnew.wxPointMM(x, y)) + # module.SetPosition(pcbnew.VECTOR2I_MM(x, y)) # board.Add(module) # pcb_pad = pcbnew.PAD(module) # pcb_pad.SetSize(pcbnew.wxSizeMM(hole["diameter"], hole["diameter"])) @@ -171,7 +171,7 @@ class CoilPlugin(pcbnew.ActionPlugin): # pcb_pad.SetDrillSize( # pcbnew.wxSizeMM(hole["diameter"], hole["diameter"]) # ) - # pcb_pad.SetPosition(pcbnew.wxPointMM(x, y)) + # pcb_pad.SetPosition(pcbnew.VECTOR2I_MM(x, y)) # module.Add(pcb_pad) # pcb_group.AddItem(pcb_hole) @@ -186,7 +186,7 @@ class CoilPlugin(pcbnew.ActionPlugin): for point in edge_cut: x = point["x"] + CENTER_X y = point["y"] + CENTER_Y - v.append(pcbnew.wxPointMM(x, y)) + v.append(pcbnew.VECTOR2I_MM(x, y)) ec.SetPolyPoints(v) board.Add(ec) @@ -201,7 +201,7 @@ class CoilPlugin(pcbnew.ActionPlugin): for point in edge_cut: x = point["x"] + CENTER_X y = point["y"] + CENTER_Y - v.append(pcbnew.wxPointMM(x, y)) + v.append(pcbnew.VECTOR2I_MM(x, y)) ec.SetPolyPoints(v) board.Add(ec) @@ -215,7 +215,7 @@ class CoilPlugin(pcbnew.ActionPlugin): for point in edge_cut: x = point["x"] + CENTER_X y = point["y"] + CENTER_Y - v.append(pcbnew.wxPointMM(x, y)) + v.append(pcbnew.VECTOR2I_MM(x, y)) ec.SetPolyPoints(v) board.Add(ec)