fullyautomated / KiJLC

KiCad BOM and CPL export for JLCSMT
BSD Zero Clause License
24 stars 14 forks source link

compatibility with KiCad 6.0.0 #3

Open thedm opened 2 years ago

thedm commented 2 years ago

In version 6.0.0 if you try using the plugin following error is occuring:

  File "xxx/KiJLC/bom2jlc.py", line 45, in <module>
    parse_pcb(netlist)
  File "xxx/KiJLC/bom2jlc.py", line 16, in parse_pcb
    modules = board.GetModules()
AttributeError: 'BOARD' object has no attribute 'GetModules'
tachiniererin commented 2 years ago

It doesn't currently support KiCad 6 because that's a moving target and not released yet. I will update it as soon as v6 is out.

sslupsky commented 2 years ago

The KiCad6 Python API is pretty much locked down now so very likely little will change that would affect your script.

tachiniererin commented 2 years ago

i'll try to get to updating and testing it on the weekend then.

sslupsky commented 2 years ago

I made the following change to init.py to resolve an issue with the script in pcbnew. It appears to have resolved the issue and the script executes without error and generates the cpl files.

diff --git a/__init__.py b/__init__.py
index c907142..92bba79 100644
--- a/__init__.py
+++ b/__init__.py
@@ -134,7 +134,10 @@ class JLCSMTPlugin(pcbnew.ActionPlugin):

     def Run(self):
         board = pcbnew.GetBoard()
-        modules = board.GetModules()
+        if hasattr(board, 'GetModules'):
+            modules = board.GetModules()
+        else:
+            modules = board.GetFootprints()

         fn = Path(board.GetFileName()).with_suffix("")

I made a similar change to bom2jlc.py and encountered an error that I have not resolved:

diff --git a/bom2jlc.py b/bom2jlc.py
index 362027e..79234bf 100755
--- a/bom2jlc.py
+++ b/bom2jlc.py
@@ -13,7 +13,10 @@ ref_ignore = ["TP", "T", "NT", "REF***", "G", "H"]
 def parse_pcb(fn):
     pcb_fn = str(Path(fn).with_suffix("")) + ".kicad_pcb"
     board = pcbnew.LoadBoard(pcb_fn)
-    modules = board.GetModules()
+    if hasattr(board, 'GetModules'):
+        modules = board.GetModules()
+    else:
+        modules = board.GetFootprints()

     for mod in modules:
         ref = mod.GetReference()

Here is the error:

Command error. Return code 1.
Traceback (most recent call last):
  File “/Users/stevenslupsky/Documents/kicad/5.99/scripting/plugins/KiJLC/bom2jlc.py”, line 2, in <module>
    import pcbnew
  File “/Applications/KiCad6/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pcbnew.py”, line 15, in <module>
    import _pcbnew
ImportError: dlopen(/Applications/KiCad6/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_pcbnew.so, 2): Library not loaded: @rpath/libwx_osx_cocoau_gl-3.1.5.dylib
  Referenced from: /Applications/KiCad6/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_pcbnew.so
  Reason: image not found

I am not sure what the problem is. I do not appear to have issues with pcbnew and the other plugins that I use (KiBOM, InteractiveHtmlBom, KiCad Action Plugins, KiCad StepUp, fcad) but I have not undertaken extensive testing. There were some packaging issues with python and macOS a few weeks ago that prevented scripting from working on macOS builds but that issue was resolved recently. For your reference, I am running the Oct 21 5.99 nightly on macOS Big Sur.

Application: KiCad

Version: (5.99.0-12896-g1860893d63), release build

Libraries:
    wxWidgets 3.1.5
    libcurl/7.64.1 SecureTransport (LibreSSL/2.8.3) zlib/1.2.11 nghttp2/1.41.0

Platform: macOS Big Sur Version 11.6 (Build 20G165), 64 bit, Little endian, wxMac

Build Info:
    Date: Oct 21 2021 13:03:55
    wxWidgets: 3.1.5 (wchar_t,wx containers)
    Boost: 1.76.0
    OCC: 7.5.3
    Curl: 7.64.1
    ngspice: 35
    Compiler: Clang 12.0.0 with C++ ABI 1002

Build settings:
    KICAD_USE_OCC=ON
    KICAD_SPICE=ON

I am finding 5.99 very stable, not perfect, but quite usable. The improvements are marvellous.

BTW, thank you for the plugin. This take a lot of the tedium and errors out of prepping files for JLCPCB.

ajquick commented 2 years ago

The change @sslupsky made had it working on Kicad 6 for me.

Triq1 commented 1 year ago

I think its broken again in Kicad 7, I'm getting this same error again

martinch14 commented 11 months ago

Over Kicad 7:

I applied the change proposed by @sslupsky, then I got this error

/usr/bin/python3 "/home/martin/.local/share/kicad/7.0/scripting/plugins/KiJLC/bom2jlc.py" "/home/martin/Escritorio/Kicad/merlin_hardware/03_Sensors_IOT_SPI_Max31865/sensor_max31865/sensor_max31865.xml" "/home/martin/Escritorio/Kicad/merlin_hardware/03_Sensors_IOT_SPI_Max31865/sensor_max31865/sensor_max31865" Error de comando. Código devuelto: 1. Traceback (most recent call last): File "/home/martin/.local/share/kicad/7.0/scripting/plugins/KiJLC/bom2jlc.py", line 83, in <module> if layer_map[ref] == "F.Cu": KeyError: 'C1'

this error was because it had never generated the plot of the layers with the PCB Editor module, after that works correctly!!

wylited commented 9 months ago

tried these changes on kicad 7 and they work properly 👍🏾