Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility with KiCad 6.0.0 #3

Open
thedm opened this issue Sep 11, 2021 · 8 comments
Open

compatibility with KiCad 6.0.0 #3

thedm opened this issue Sep 11, 2021 · 8 comments

Comments

@thedm
Copy link

thedm commented Sep 11, 2021

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
Copy link
Contributor

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
Copy link

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

@tachiniererin
Copy link
Contributor

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

@sslupsky
Copy link

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
Copy link

ajquick commented Jun 19, 2022

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

@Triq1
Copy link

Triq1 commented Jul 10, 2023

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

@martinch14
Copy link

martinch14 commented Jul 24, 2023

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
Copy link

wylited commented Oct 14, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants