From 8ff1cba906cb61fc2bc393aba2390b601791d78b Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 10 Feb 2023 10:11:44 -0300 Subject: [PATCH] [Drill] Support for KiCad v7 - Point -> Vector - Rect -> Box --- kibot/gs.py | 8 ++++++++ kibot/out_excellon.py | 7 ++++--- kibot/out_gerb_drill.py | 7 ++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/kibot/gs.py b/kibot/gs.py index 21cd8c55..a87bb7ce 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -256,6 +256,12 @@ class GS(object): return title_block.GetComment4() return '' + @staticmethod + def p2v_k7(point): + """ KiCad v7 changed various wxPoint args to VECTOR2I. + This helper changes the types accordingly """ + return pcbnew.VECTOR2I(point) if GS.ki7 else point + @staticmethod def get_modules(): if GS.ki6: @@ -485,6 +491,8 @@ class GS(object): @staticmethod def create_eda_rect(tlx, tly, brx, bry): + if GS.ki7: + return pcbnew.BOX2I(pcbnew.VECTOR2I(tlx, tly), pcbnew.VECTOR2I(brx-tlx, bry-tly)) return pcbnew.EDA_RECT(pcbnew.wxPoint(tlx, tly), pcbnew.wxSize(brx-tlx, bry-tly)) # @staticmethod diff --git a/kibot/out_excellon.py b/kibot/out_excellon.py index 293e68d3..f2ca9bef 100644 --- a/kibot/out_excellon.py +++ b/kibot/out_excellon.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2020-2021 Salvador E. Tropea -# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial +# Copyright (c) 2020-2023 Salvador E. Tropea +# Copyright (c) 2020-2023 Instituto Nacional de Tecnología Industrial # License: GPL-3.0 # Project: KiBot (formerly KiPlot) from pcbnew import EXCELLON_WRITER from .out_any_drill import AnyDrill +from .gs import GS from .macros import macros, document, output_class # noqa: F401 ZF = {'DECIMAL_FORMAT': EXCELLON_WRITER.DECIMAL_FORMAT, @@ -37,7 +38,7 @@ class ExcellonOptions(AnyDrill): def _configure_writer(self, board, offset): drill_writer = EXCELLON_WRITER(board) - drill_writer.SetOptions(self.mirror_y_axis, self.minimal_header, offset, self.pth_and_npth_single_file) + drill_writer.SetOptions(self.mirror_y_axis, self.minimal_header, GS.p2v_k7(offset), self.pth_and_npth_single_file) drill_writer.SetRouteModeForOvalHoles(self.route_mode_for_oval_holes) drill_writer.SetFormat(self.metric_units, ZF[self.zeros_format], self.left_digits, self.right_digits) self._unified_output = self.pth_and_npth_single_file diff --git a/kibot/out_gerb_drill.py b/kibot/out_gerb_drill.py index 31562dd5..0efd0da8 100644 --- a/kibot/out_gerb_drill.py +++ b/kibot/out_gerb_drill.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2020-2021 Salvador E. Tropea -# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial +# Copyright (c) 2020-2023 Salvador E. Tropea +# Copyright (c) 2020-2023 Instituto Nacional de Tecnología Industrial # License: GPL-3.0 # Project: KiBot (formerly KiPlot) from pcbnew import GERBER_WRITER +from .gs import GS from .out_any_drill import AnyDrill from .macros import macros, document, output_class # noqa: F401 @@ -17,7 +18,7 @@ class Gerb_DrillOptions(AnyDrill): drill_writer = GERBER_WRITER(board) # hard coded in UI? drill_writer.SetFormat(5) - drill_writer.SetOptions(offset) + drill_writer.SetOptions(GS.p2v_k7(offset)) return drill_writer