From 3ea66e0b32247fd1abd933aa4ac14d6195ca8fe9 Mon Sep 17 00:00:00 2001 From: Egil Kvaleberg Date: Wed, 29 Dec 2021 03:02:48 +0100 Subject: [PATCH 1/2] Uodate to latest KiCAD 6.0 release. GetModules() is depreceated, and no longer available. --- __init__.py | 2 +- bom2jlc.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index c907142..9c699e9 100644 --- a/__init__.py +++ b/__init__.py @@ -134,7 +134,7 @@ def defaults(self): def Run(self): board = pcbnew.GetBoard() - modules = board.GetModules() + modules = board.GetFootprints() # was GetModules() but this does not work with KiCAD 6.0 fn = Path(board.GetFileName()).with_suffix("") diff --git a/bom2jlc.py b/bom2jlc.py index 362027e..8689bc2 100755 --- a/bom2jlc.py +++ b/bom2jlc.py @@ -13,7 +13,7 @@ def parse_pcb(fn): pcb_fn = str(Path(fn).with_suffix("")) + ".kicad_pcb" board = pcbnew.LoadBoard(pcb_fn) - modules = board.GetModules() + modules = board.GetFootprints() # was GetModules() but this does not work with KiCAD 6.0 for mod in modules: ref = mod.GetReference() From e1882e53356ebb665a1d7fd6b4b2bb914363f1c4 Mon Sep 17 00:00:00 2001 From: Egil Kvaleberg Date: Wed, 29 Dec 2021 14:18:56 +0100 Subject: [PATCH 2/2] Apply aux origin, i.e. use same coordinates as for the Gerber, drill and pos files --- __init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index 9c699e9..0b22207 100644 --- a/__init__.py +++ b/__init__.py @@ -135,6 +135,9 @@ def defaults(self): def Run(self): board = pcbnew.GetBoard() modules = board.GetFootprints() # was GetModules() but this does not work with KiCAD 6.0 + origin = board.GetDesignSettings().GetAuxOrigin() + origin_x = Decimal(origin.x) / Decimal(1000000) + origin_y = Decimal(origin.y) / Decimal(-1000000) fn = Path(board.GetFileName()).with_suffix("") @@ -192,8 +195,8 @@ def Run(self): print(f"rotating {ref} ({footprint}): prev {rot}, new {new_rot}") rot = new_rot - x = str(mid_x) + "mm" - y = str(mid_y) + "mm" + x = str(mid_x - origin_x) + "mm" + y = str(mid_y - origin_y) + "mm" if layer == "F.Cu": topw.writerow([ref, x, y, "top", rot])