Giter VIP home page Giter VIP logo

kicadscripts's People

Contributors

dansgiesbrecht avatar gregdavill avatar joric avatar kekiefer avatar mattyams avatar qbort avatar whatnick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kicadscripts's Issues

plot_board fails on render

See output:

ab@xps ~/pub/kicadScripts $ python plot_board.py /home/ab/folktek/garden-limited/nano/nano.kicad_pcb
(1, '', 'CopperInner')
Traceback (most recent call last):
  File "plot_board.py", line 420, in <module>
    render(plot_plan, project_name + '-Front.png')
  File "plot_board.py", line 310, in render
    svgData.openSVG(pctl.GetPlotFileName())
  File "plot_board.py", line 70, in openSVG
    root = ET.parse(filename)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 656, in parse
    parser.feed(data)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1653, in feed
    self._raiseerror(v)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1517, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: unbound prefix: line 15, column 0

Not sure where to begin with this one.
I tried to:
pip install --user elementpath
...but I don't think that was the issue as I didn't get a "no module" error...

Any ideas? Thanks.
plot_gerbers seems to work fine...

Not able to run the board plots on a macOS

Hi, I'm trying to use your board plot scripts on a Mac running Mojave. I followed this thread on the KiCad forum to modify the paths to run the files using the default python included with KiCad. And then added paths to the Inkscape app. When I run the plot_board.py with the KiCad_pcb file I get the following errors:

b dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages/_pcbnew.so being ignored in restricted program because of @executable_path dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/KiCad/kicad.app/Contents/Frameworks/python/site-packages/../../libwx_osx_cocoau_gl-3.0.0.dylib being ignored in restricted program because of @executable_path dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/KiCad/kicad.app/Contents/Frameworks/python/site-packages/../../libwx_osx_cocoau-3.0.0.dylib being ignored in restricted program because of @executable_path dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/KiCad/kicad.app/Contents/Frameworks/python/site-packages/../../libkicad_3dsg.2.0.0.dylib being ignored in restricted program because of @executable_path dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/KiCad/kicad.app/Contents/Frameworks/python/site-packages/../../libGLEW.2.2.dylib being ignored in restricted program because of @executable_path dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/KiCad/kicad.app/Contents/Frameworks/python/site-packages/../../libcairo.2.dylib being ignored in restricted program because of @executable_path dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/KiCad/kicad.app/Contents/Frameworks/python/site-packages/../../libpixman-1.0.dylib being ignored in restricted program because of @executable_path dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/KiCad/kicad.app/Contents/Frameworks/python/site-packages/../../libfontconfig.1.dylib being ignored in restricted program because of @executable_path dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/KiCad/kicad.app/Contents/Frameworks/python/site-packages/../../libfreetype.6.dylib being ignored in restricted program because of @executable_path dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/KiCad/kicad.app/Contents/Frameworks/python/site-packages/../../libpng16.16.dylib being ignored in restricted program because of @executable_path Fatal Python error: PyThreadState_Get: no current thread [1] 87057 abort python plot_board.py

What am I missing?

No Attribute 'SetLineWidth' in KiCad nightly

Hi,

I'm using a pretty recent nightly version of KiCad and always get this output when using your scripts:

C:\Users\Tobias\Desktop\kicadScripts-master>"C:\Program Files\KiCad\bin\python.exe" plot_board.py "C:\Users\Tobias\Documents\GitHub\uDice\uDice\uDice.kicad_pcb"
Traceback (most recent call last):
  File "plot_board.py", line 425, in <module>
    popt.SetLineWidth(FromMM(0.35))
AttributeError: 'PCB_PLOT_PARAMS' object has no attribute 'SetLineWidth'

Not sure if it's just the attribute name that has been changed or whether there are more changes.

KiCad7 support issue

I use kicad7 and plot script seems to be completely incompatible with it... Do you have a way to make it compatible for this great tool?

KiCAD 5.1.6 not working in combination with plot_board.py

Okay, so far thanks a lot for this awesome script, regarding this video, it seems very nice and easy to use, but.....

It tried it out yesterday and it didn't work for me. My setup:

  • KICAD 5.1.6 installed via ppa
  • Linux Mint 19, Cinnamon
  • Inkscape 0.92.3
  • Python: Python 2.7.17, Python 3.6.9
    python --version or python3 --version

So basically, when I run python plot_board.py with the input and output parameters, I got the following error messages:
PCBNew not found, are you using KiCAD included Python ? But in fact, I have installed KiCAD and regarding this command, I have python and the module pcbnew installed as well:

~ dpkg --listfiles kicad | grep python
/usr/lib/python3  
/usr/lib/python3/dist-packages 
/usr/lib/python3/dist-packages/_pcbnew.so 
/usr/lib/python3/dist-packages/pcbnew.py 

It seems to be that my KiCAD installation is now linked to the python3 and not to python version 2.7.17 as provided by the script. Maybe it is because KiCAD now switched to the newer python version... So i went further to get the job done by trying out running the script with python3:

~ python3 plot_board.py FILE.kicad_pcb
... 
Merging layers...
Rasterizing...
Traceback (most recent call last):
  File "plot_board.py", line 438, in <module>
    render(plot_plan, project_name + '-Front.png')
  File "plot_board.py", line 356, in render
    if len(version) > 1 and version[1] < "1.0":
TypeError: '<' not supported between instances of 'bytes' and 'str'

This issue could be fixed by removing the and version[1] < "1.0" in line 356. I am not sure if this is the way to fix it, but with this I was able to go ahead to went into the next issue :D:D:D:

~ python3 plot_board.py FILE.kicad_pcb
...
Merging layers...
Rasterizing...

** (inkscape:7896): WARNING **: 08:19:53.558: Cannot parse export area '71.89547122100001:323.425711221:955.161148779:736.3570487789999'; use 'x0:y0:x1:y1'. Nothing exported.
Traceback (most recent call last):
  File "plot_board.py", line 438, in <module>
    render(plot_plan, project_name + '-Front.png')
  File "plot_board.py", line 363, in render
    final_svg,
  File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)

Okay, again an issue, but nothing to worry about. I thought maybe it is an "casting" issue and Inkscape doesn't accept float values to export an area from an svg file. So i tried it out by changing line 359 and line 368 from

format(x0,y0,x1,y1) to format(int(x0),int(y0),int(x1),int(y1)).

Yeah and after that, I finally got the output I was searching for:

~ python3 plot_board.py FILE.kicad_pcb
...
Merging layers...
Rasterizing...
DPI: 1200
Background RRGGBBAA: 998060ff
Area -955:323:-71:736 exported to 11050 x 5163 pixels (1200 dpi)
Bitmap saved as: /DIRECTORY/FILE-Back.png

Okay, to sum it up:

  1. First we have to check which python version your KiCAD version is working with. In case of python3, we have to run the script with the command python3 instead of python
  2. A few script changes which are mentioned above has to be done:
    • line 356: remove and version[1] < "1.0"
    • line 359 and line 368: change format(x0,y0,x1,y1) to format(int(x0),int(y0),int(x1),int(y1))

Note: This fix worked for me and my setup. I didn't tried it out on Windows or other Linux distributions. Moreover, I didn't try the plot_gerber.py script at all, so I have no hints what to change there to get it working. I am not quite sure if my provided solution is a good one, because I am not familiar with python at all, I am more a C++ / Java guy :D.

What is left to do:

  • I will create a fork of your script and add my changes
  • @gregdavill is it possible that you check my provided solution whether it makes sense or not?
  • plot_gerber.py script has to be checked as well
  • We have to take into account some other operating systems and setups to verify the solutions as a proper one

I hope I was able to help others who faced or will face the same problem ;) If any questiosn are left, feel free to contact me!

Broken invert function when drawing the solder mask

I am running nightly release 20211127-055350-b8b8c0d34 on macOS and I've experienced issues when plotting a board, where the solder mask wouldn't be drawn.

I have investigated a little and it happens within the addSvgImageInvert function, where we would like to create a rectangle the size of the board and use the top layer as a mask on that rectangle.

It appears that the GetWidth, GetHeight functions both return 0, which explains why there isn't any solder mask on the outputted image.

I haven't found anyone else having this issue unfortunately. Did you ever come across anything similar ?

compute-Back

No rendering of references or values

No silk for resistors here: https://github.com/joric/nrfmicro/tree/devel
Image: https://i.imgur.com/IiW58gu.jpg
Maybe you could figure why faster than me.
Also PCB outline is wrong but that's probably should be another issue.
Kicad (5.1.5)-3
Inkscape 0.92.5 (I also had to comment out version check as there's no --export-type=png in the 0.92 anymore but it also totally doesn't work with 1.0 beta (1.0 just doesn't rasterize anything).
plot_board.py

- if len(version) > 1 and version[1] < "0.9":
+ if True:

Also I had to copy _pcbnew.pyd to the scripts directory. Also import _pcbnew try/catch block hides the message about ImportError: DLL load failed: The specified procedure could not be found.

Does not support Inkscape >1.0

Inkscape >1.0 added changes to the arguments that need to be parsed in order to export PNGs.
We'll need to add a way to detect the version of inkscape and adapt what arguments are passed in order to support both the new and distro version of inkscape.

python plot_board.py ../FireCam/hardware/FireCam/ButterStick.kicad_pcb
(0, '', 'Copper')
(39, 'Invert', 'SolderMask')
(35, '', 'Paste')
(37, '', 'Silk')
(44, '', 'Edge')
Merging layers...
Rasterizing...
Unknown option --export-png
Traceback (most recent call last):
  File "plot_board.py", line 435, in <module>
    render(plot_plan, project_name + '-Front.png')
  File "plot_board.py", line 369, in render
    final_svg,
  File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['inkscape', '--export-area=399.251361337:280.666643657:671.150834585:544.440526221', '--export-dpi=1200', '--export-png', '/home/greg/projects/FireCam/hardware/FireCam/plot/ButterStick-Front.png', '--export-background', '#5b4b43', '/home/greg/projects/FireCam/hardware/FireCam/plot/temp/ButterStick-merged.svg']' returned non-zero exit status 1.

missing GetBoardEdgesBoundingBox attribute

Hello, I am trying this with Kicad 4.07 and python 2.7 on Ubuntu and I get the following error

python plot_board.py ../board.kicad_pcb 
12:08:38: Debug: Skipping general section token 'links' 
12:08:38: Debug: Skipping general section token 'area' 
12:08:38: Debug: Skipping general section token 'drawings' 
12:08:38: Debug: Skipping general section token 'tracks' 
12:08:38: Debug: Skipping general section token 'zones' 
12:08:38: Debug: Skipping general section token 'symbol' 
Traceback (most recent call last):
  File "plot_board.py", line 367, in <module>
    bb = board.GetBoardEdgesBoundingBox()
  File "/usr/lib/python2.7/dist-packages/pcbnew.py", line 4806, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, BOARD, name)
  File "/usr/lib/python2.7/dist-packages/pcbnew.py", line 83, in _swig_getattr
    raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'BOARD' object has no attribute 'GetBoardEdgesBoundingBox'

I can confirm I do not have GetBoardEdgesBoundingBox in pcbnew.py the line count is significantly lower than http://docs.kicad-pcb.org/doxygen-python/pcbnew_8py_source.html#l19204. Curious if you have any ideas!

Fail to find inkscape on windows

Issue received via email:

I just started using your software called "plot_board.py" and immediately had some errors that I don't know how to fix. I would open an issue in GitHub, but unfortunately I don't actually know what is failing. Here is the output I got:

[A bunch of numbers]

Merging layers...
Rasterizing...
Traceback (most recent call last):
  File "plot_board.py", line 439, in <module>
    render(plot_plan, project_name + '-Front.png')
  File "plot_board.py", line 356, in render
    version = subprocess.check_output(['inkscape', '--version'], stderr=subprocess.STDOUT).split()
  File "c:\Program Files\KiCad\lib\python2.7/subprocess.py", line 217, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "c:\Program Files\KiCad\lib\python2.7/subprocess.py", line 325, in __init__
    errread, errwrite)
  File "c:\Program Files\KiCad\lib\python2.7/subprocess.py", line 575, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Do you know what's going on here? Is it a problem with Inkscape? I have Inkscape 0.92, which I installed using just the normal installer. I'm on Windows.
Any help is appreciated!

This seems to be related to finding the path to inkscape. I'm generally using these scripts on linux, where calling inkscape just works. But I think on windows we'll need to actually define the full-path.

If you want to try it, you'll need to edit these calls to inkscape: https://github.com/gregdavill/kicadScripts/blob/master/plot_board.py#L356-L375

Oval pads on rotated footprint appear horizontal

Hello,

First of all thank you so much for those scripts, they are amazing and the renders are gorgeous!

I have a board with a USB connector at a 35° angle. It has two oval pads, but on the renders, the pads show up horizontally instead of being at an angle.

I just thought I'd let you know :)

Screen Shot 2019-04-21 at 7 49 12 PM

Mask errors in Inkscape >1.0

Soldermask generation no longer includes cutouts when rendering with inkscape >1.0.

I suspect this is to do with a different parsing method of the svg structure in the new inkscape, our svg mask is no longer being generated correctly.

Failed on Rasterizing

Hi,
I'm using kicad 5.1.4 and a recent clone of your scripts. Inkscape is 0.92.

It happens with any kicad project. If you need any more info feel free to ask.

Thank you

Merging layers...
Rasterizing...

** (inkscape:32483): WARNING **: 15:26:36.720: Cannot parse export area '438.269521221:438.534051221:699.209478779:552.093008779'; use 'x0:y0:x1:y1'. Nothing exported.
Traceback (most recent call last):
  File "../kicadScripts/plot_board.py", line 420, in <module>
    render(plot_plan, project_name + '-Front.png')
  File "../kicadScripts/plot_board.py", line 355, in render
    final_svg,
  File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['inkscape', '--export-area=438.269521221:438.534051221:699.209478779:552.093008779', '--export-dpi=1200', '--export-png', '/home/ze/development/pcb/plot/pcb-Front.png', '--export-background', '#998060', '/home/ze/development/pcb/plot/temp/pcb-merged.svg']' returned non-zero exit status 1.

Getting the plot_board script up and running on MacOS.

First of all, thanks for your awesome work and inspiring tweets. It really pushes me to get better at electronics.

So, now for the issue: I'm trying to get the code up and running on MacOS (10.14.3). But unfortunately I'm getting some unexpected results which might have something to do with masking.

Initially I just tried running python plot_board.py path/to/kicad_project.kicad_pcb but this gave the following error on MacOS:

Traceback (most recent call last):
  File "plot_board.py", line 9, in <module>
    import pcbnew
ImportError: No module named pcbnew

With the help of the KiCad forum I figured out I needed to make some modifications to the plot_board script:

  • Add a shebang line to the top: #!/Applications/Kicad/kicad.app/Contents/Frameworks/Python.framework/Versions/Current/bin/python
  • Use the following code after the shebang line:
import sys
sys.path.insert(
    0,
    "/Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages/")
  • Modify the executalbe path of inkscape on line 311 to: /Applications/Inkscape.app/Contents/Resources/bin/inkscape
  • Make the script executable: chmod +x plot_board.py

After these changes, I'm able to run the script using the following command: ./plot_board.py path/to/kicad_project.kicad_pcb

The script still gives a bunch of errors:

** (inkscape-bin:1123): WARNING **: attribute 'mask' given as CSS
** (inkscape-bin:1123): WARNING **: attribute 'mask' given as CSS
** (inkscape-bin:1123): WARNING **: attribute 'mask' given as CSS
** (inkscape-bin:1123): WARNING **: attribute 'mask' given as CSS
** (inkscape-bin:1123): WARNING **: attribute 'mask' given as CSS
...

But it does generate an image. My guess is these errors come from the fact that the mask is used via the style attribute in stead of using the mask attribute on line 146, 152 and 181. When I modify these lines to use the mask attribute, the error disappears.

This leaves us with the real issue: The solder pads remain black (as opposed to a copper color) And the board soldermask remains square although the board's edge cuts is a circle.

See the following example of my result:

SoundCandle-Back

Version Information:

  • Kicad: 5.1
  • MacOS: 10.14.3
  • Inkscape 0.92.4

Unfortunately I'm not experienced with Python and Kicad enough to solve this issue on my own. I'f I do manage to figure it out, I'll make sure to send a PR.

Transparent areas turn black in Fusion360

Hi, when having transparent areas i.e. no copper and no soldermask, the board turns black as there is no color there when using the rendered image as a material (not decal).
This could be fixed by generating a layer of yellow-ish to represent the PCB FR4 color and have it as the base layer.

Warning Overflow KiROUND during plot_board

I'm using KiCAD 6.0.1, Inkscape 1.1 and I'm getting this message lot of times (with distinct numbers) while running plot_board.py.

12:51:02: Warning: Overflow KiROUND converting value -377147830500.000000 to 湩t㩸ϛ淣뻀崀逇რ翼

(this kind of message prompts 19 times while plotting a small dual-layer board.)

At the end I had success ploting it.

Is there a way to supress this warning?

Kicad detail version:

Application: KiCad (64-bit)

Version: (6.0.1), release build

Libraries:
	wxWidgets 3.1.5
	libcurl/7.78.0-DEV Schannel zlib/1.2.11

Platform: Windows 10 (build 22000), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
	Date: Jan 15 2022 13:36:27
	wxWidgets: 3.1.5 (wchar_t,wx containers)
	Boost: 1.76.0
	OCC: 7.5.0
	Curl: 7.78.0-DEV
	ngspice: 35
	Compiler: Visual C++ 1929 without C++ ABI

Build settings:
	KICAD_USE_OCC=ON
	KICAD_SPICE=ON

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.