Giter VIP home page Giter VIP logo

pcbdraw's Introduction

PcbDraw

Convert your KiCAD boards into nice looking 2D drawings suitable for pinout diagrams. Never draw them manually again!

example

This tool takes a KiCAD board (.kicad_pcb file) and produces a 2D nice looking drawing of the board as an SVG file. This allows you to quickly and automatically create awesome pinout diagrams for your project. These diagrams are much easier to read than a labeled photo of a physical board or an actual KiCAD design.

You and your users will love them!

PcbDraw also comes with a small utility called Populate which allows you to easily specify & maintain nice looking HTML or Markdown population manuals.

example

And, also, as a bonus it allows you to programmatically obtain 3D-rendered previews of your boards (e.g., in CI).

Installation

PcbDraw is a stand-alone CLI tool distributed as a Python package pcbdraw. It also requires Inkscape 1 or librsvg installed. Read more details in the installation guide.

Usage

There are two separate guides:

There are also examples of usage in the examples directory.

PcbDraw seems to be broken!

Please, read FAQ first. If it does not answer your problem, feel free to open issue on GitHub.

Contributing

Feel free to submit issues and pull requests!

Future Work

  • make reasonably complete module library

pcbdraw's People

Contributors

adamws avatar andresmanelli avatar arturo182 avatar electro707 avatar hdr avatar jarekparal avatar joric avatar leoheck avatar luzpaz avatar n-i-x avatar nobodywasishere avatar nopeppermint avatar pintert3 avatar pointhi avatar set-soft avatar smkent avatar sur5r avatar tu500 avatar wifasoi avatar yaqwsx 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pcbdraw's Issues

add a color for the soldermask

add an option to specify the color of the solder mask.
So when there is no solder mask, it will reveal the color of the board.
This issue is more an enhancement than an issue.

Solve Windows compatibility

Currently, PcbDraw has a dependency on several Python libraries. This is a problem on Windows, where KiCAD brings its own, binary incompatible, version of Python - the dependencies cannot be installed (it would be necessary to compile them using Msys2).

The proposed solution - split PcbDraw into two executables - the first one, with no dependencies, exports all necessary data from KiCAD to files, the second one (with Python dependencies) finishes the work. There will be a wrapper to automate the process; on Windows, it will run the first step using the KiCAD's Python, the second step is executed via system Python. This also solves the problem with Python2 compatibility on Windows - it should be fairly easy to write a Python2 compatible first stage.

Drill holes supported?

Are drill holes supported by PcbDraw? I'm not seeing any rendered in the drawings I generate, but I wasn't certain if that is a bug or something not yet supported.

Thank you again for the fantastic tool!

Default configuration file

It would be very nice to have a configuration file (json type or any other) with the default path of the style file and library path, which would be used in case of not providing any path as an argument.
This would greatly simplify the invocation of the PcbDraw command

Thanks

Draw only components of the current side of board

I'm trying to draw a PCB with PCBDraw, but i'm facing an issue:

  • When I draw the front side of the board, it also draws the components present on the BACK of the board.
  • Same when I draw the back.

I could write 2 filtering files, but that's a bit long. Would it be possible to filter every SMD components from the other side of the board ?
Thanks.

Obsolete argparse dependency

The current setup.py asks for argparse package.

But this functionality became part of standard Python on v3.2. The current version is 3.8.3, and even the conservative Debian stable is using 3.7.3 (released on march 2019). Python 3.2 was released in february 2011.

So I think this dependency isn't really needed. I guess it got there when PcbDraw was Python 2, but for Python 3 there is no need to install argparse as a separated package.

BTW: I'm currently using docopt, well in fact a patched version to support args.argument (in addition to args["argument"]). This package gets the command line specification from the doctring.

Board edge recognition issues

I just tried this great tool, and I've found some flaws:

  • The board edge is not respected: The copper outside the board edge should be removed. For example in edge connectors.
  • With irregular board shapes, the mask is not painted correctly, (currently off the board).

The image is the copper layer (top) and the board edge along the soldermask (below). You can see these faults:

imagen

KiCAD 6.0 vias rendered as silkscreen

It seems that PCBdraw is rendering vias from KiCAD 6 files as silkscreen now.

Tested it by setting the silkscreen color to red and got this as a result.
pcb_render

Is this intentional?
Imho it does look kind of weird when all the vias are white.

Ideally they should have the color of the board.

[MacOS] ModuleNotFoundError: No module named 'pcbnew'

Traceback (most recent call last):
  File "/usr/local/bin/pcbdraw", line 5, in <module>
    from pcbdraw.pcbdraw import main
  File "/usr/local/lib/python3.8/site-packages/pcbdraw/pcbdraw.py", line 18, in <module>
    import pcbnew
ModuleNotFoundError: No module named 'pcbnew'

Anyone running PcbDraw on MacOS successfully? I'm not this familiar with Python and I can't seem to find any related issues for MacOS. I installed through homebrew.

Application: Pcbnew
Version: (5.1.6-0-10_14), release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.64.1 SecureTransport (LibreSSL/2.8.3) zlib/1.2.11 nghttp2/1.39.2
Platform: macOS Catalina Version 10.15.6 (Build 19G73), 64 bit, Little endian, wxMac
Build Info:
    wxWidgets: 3.0.4 (wchar_t,STL containers,compatible with 2.8)
    Boost: 1.72.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.54.0
    Compiler: Clang 9.0.0 with C++ ABI 1002

Build settings:
    USE_WX_GRAPHICS_CONTEXT=ON
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=OFF
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

Fixed plot origin?

Am trying to plot versions of boards that are in a VCS and then use ImageMagick to identify the differences. Using your script, I am now able to produce files like these (where green is in the new plot but not the old and red was in the old but not the new).

diff-74b1-b1d3
diff-74b1-b1d3

diff-b1d3-192a
diff-b1d-192a

Sometimes, however, the origin of the plot is shifted and I get this effect:

diff2.

Do you know how is the plot origin is set and if it can be fixed? I have had some success by setting the <g transform="translate(-xxxx, -xx)" lines of both plots to the same values but I am unsure as to how the plotting origin is determined. I am also keen to use your xml tree to parse where the diffs have occurred.

EdgeCut detection not working properly

I stumbled upon this really weird issue yesterday where some edgecuts are apparently not fully recognized and are not properly cut out of the PCB substrate layer

It works perfectly fine in KiCADs own 3D renderer and when exported as gerber files it is rendered correctly in other viewers (like tracespace) too.

So far I couldn't find anything wrong with those edgecuts in the kicad files itself when compared to the other working edgecuts.

The file that I'm trying to render is this one:
https://raw.githubusercontent.com/kb-elmo/sesame/master/extras/switchplate.kicad_pcb

Add option to hide references and values

I have been playing around with PcbDraw and it's very neat :). One thing I'm wondering is if there is a way to not show the references and values on the silk screen layer.

I was looking through the code to add an option for this but couldn't find where they are added to the SVG. If you can point me in the right direction, I can try to add an option to hide them.

kicad 6.0 + windows 10 installation guide request add one more option

Hello,
windows 10 updated and latest build with Kicad 6.0
installed pcbdraw without issues but hen i tried "pcbdraw --help" or "pcbdraw" command get theese errors :

C:\Users\Asus\Documents\kicad\6.0>pcbdraw
Traceback (most recent call last):
  File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\wand\api.py", line 151, in <module>
    libraries = load_library()
  File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\wand\api.py", line 140, in load_library
    raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: []

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\KiCad\6.0\bin\Scripts\pcbdraw.exe\__main__.py", line 4, in <module>
  File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\pcbdraw\pcbdraw.py", line 16, in <module>
    from wand.api import library
  File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\wand\api.py", line 175, in <module>
    raise ImportError('MagickWand shared library not found.\n'
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
  https://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows

i think install guide need some update too for windows ;

  1. ImageMagick library need to be installed (like mine fresh windows and kicad installations)
    https://imagemagick.org/script/download.php#windows

resim

resim

after that voila :

* KiCad 6.0 Command Prompt
************************************
You may now invoke python or pip targeting kicad's install


C:\Users\Asus\Documents\kicad\6.0>pcbdraw
usage: pcbdraw [-h] [--version] [-s STYLE] [-l LIBS] [-p] [-m REMAP] [-c] [--no-drillholes] [-b] [--mirror]
               [-a HIGHLIGHT] [-f FILTER] [-v] [--silent] [--dpi DPI] [--no-warn-back] [--shrink SHRINK]
               board output
pcbdraw: error: the following arguments are required: board, output

C:\Users\Asus\Documents\kicad\6.0>pcbdraw -- help
usage: pcbdraw [-h] [--version] [-s STYLE] [-l LIBS] [-p] [-m REMAP] [-c] [--no-drillholes] [-b] [--mirror]
               [-a HIGHLIGHT] [-f FILTER] [-v] [--silent] [--dpi DPI] [--no-warn-back] [--shrink SHRINK]
               board output
pcbdraw: error: the following arguments are required: output

Thanks for your great work and plugins.

PcbDraw fails on negative coordinates

Found and fixed this issue when trying to render a board that is partly drawn using negative coordinates.

I'm relatively new to KiCAD, and couldn't figure out how to move the coordinate origin to the center of the workspace. I needed to draw a symmetrical board and didn't want to complicate the math, so my hack was to draw my board relative to the document origin in the top left. The resulting board uses negative coordinates for half of its geometry. Running PcbNew (version 0.6.0, from the Arch repo) on this board produces the following error trace:

Traceback (most recent call last):
  File "/usr/bin/pcbdraw", line 33, in <module>
    sys.exit(load_entry_point('PcbDraw==0.6.0', 'console_scripts', 'pcbdraw')())
  File "/usr/lib/python3.8/site-packages/pcbdraw/pcbdraw.py", line 792, in main
    board_cont.append(get_board_substrate(board, style, not args.no_drillholes, args.back))
  File "/usr/lib/python3.8/site-packages/pcbdraw/pcbdraw.py", line 444, in get_board_substrate
    process(container, f, os.path.join(tmp, svg_file), colors, boardsize)
  File "/usr/lib/python3.8/site-packages/pcbdraw/pcbdraw.py", line 328, in process_board_substrate_base
    clipPath.append(get_board_polygon(extract_svg_content(read_svg_unique(source))))
  File "/usr/lib/python3.8/site-packages/pcbdraw/pcbdraw.py", line 276, in get_board_polygon
    elements.append(SvgPathItem(svg_element.attrib["d"]))
  File "/usr/lib/python3.8/site-packages/pcbdraw/pcbdraw.py", line 50, in __init__
    raise SyntaxError("Only paths with absolute position are supported")
SyntaxError: Only paths with absolute position are supported

I traced this down to the regexp in class SvgPathItem that tries to split the given SVG path. It doesn't handle the following input correctly:

M-6496.06 -6496.06 A2362.2 2362.2 0.0 0 0 -4133.86 -8858.27

The fix is trivial:

diff --git a/pcbdraw/pcbdraw.py b/pcbdraw/pcbdraw.py
index 843e8a9..ebdf9ae 100755
--- a/pcbdraw/pcbdraw.py
+++ b/pcbdraw/pcbdraw.py
@@ -45,7 +45,7 @@ float_re = r'([-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?)'
 
 class SvgPathItem:
     def __init__(self, path):
-        path = re.sub(r"([MLA])(\d+)", r"\1 \2", path)
+        path = re.sub(r"([MLA])(-?\d+)", r"\1 \2", path)
         path = re.split("[, ]", path)
         path = list(filter(lambda x: x, path))
         if path[0] != "M":

Now it works.

Feature Discussion: Resistor Color Code and Markings

I am creating this issue to discuss the potential feature of having PcbDraw also fill in a resistor's color code (in the case of a THT resistor) or number markings (in the case of a SMD resistor) if the footprint drawing supports it. I got this feature preliminary working on my feature_res_color branch of my fork, which needs my tht_resistor branch for my footprint library fork
image

The way it detects the resistance is by analyzing the value of the footprint, and assumes a 5% tolerance for now. If this feature was to be added, perhaps it can split the value by spaces and analyze it for a tolerance value as well.
The bands on the footprint drawing is detected using the IDs of the band.

The colors are for now manually defined. Perhaps this can be moved to a new styles json file and allow user-defined resistor colors?

The codebase for this is hackish right now, and I want to clean it up before I call it complete. I also need to add in marking SMD resistors (probably thru an ID for an empty placehold text and changing it's inner node's text.

Kicad nightly (5.99)

Having trouble generating for nightly projects, i was under the impression specifying the python path was enough, but I'm getting this error:

Traceback (most recent call last):
  File "/usr/bin/pcbdraw", line 33, in <module>
    sys.exit(load_entry_point('PcbDraw==0.6.1', 'console_scripts', 'pcbdraw')())
  File "/usr/lib/python3.9/site-packages/pcbdraw/pcbdraw.py", line 793, in main
    board_cont.append(get_board_substrate(board, style, not args.no_drillholes, args.back))
  File "/usr/lib/python3.9/site-packages/pcbdraw/pcbdraw.py", line 433, in get_board_substrate
    popt.SetTextMode(pcbnew.PLOTTEXTMODE_STROKE)
AttributeError: module 'pcbnew' has no attribute 'PLOTTEXTMODE_STROKE'

Is this due to some api change?

version 5.99.0_12876_gfb5fef9f5f

Works only if --no-drillholes option is set

I have managed to get this to work on macOS (I had had to copy a system python executable into Kicad and stick lxml into he associated site-packages.

The script runs but only if I select the --no-drillholes option, otherwise it fails with the following memory leak issue.

Kicad nightly from July 17 (which has been stable for me for a while).

✔ xxxxxxxx:PcbDraw [ master | ✚ 1 …2 ] ➭ ./pcbdraw.py ../PcbDraw-Lib/KiCAD-base/  --no-drillholes out2.svg /Users/xxxxxx/EDA_Workspace/trial_git/ThermocoupleLogger.kicad_pcb
Namespace(board='/Users/xxxxxxxx/EDA_Workspace/trial_git/ThermocoupleLogger.kicad_pcb', libraries=['../PcbDraw-Lib/KiCAD-base/'], list_components=False, no_drillholes=True, output='out2.svg', placeholder=False, remap=None, style=None)
Please ignore following debug output of KiCAD Python API
End of KiCAD debug output
/Volumes/SSD/workspace/osx-kicad-adam-head/kicad/common/lset.cpp(769): assert "unsigned( aLayer ) < PCB_LAYER_ID_COUNT" failed in ToLAYER_ID().
Warning: component 'MountingHole_5.5mm' from library 'Mounting_Holes' was not found
Warning: component 'MountingHole_3.2mm_M3' from library 'Mounting_Holes' was not found
Warning: component 'TO-220_Vertical' from library 'TO_SOT_Packages_THT' was not found
Warning: component 'TO-126_Vertical' from library 'TO_SOT_Packages_THT' was not found
....


✔ xxxxxxxxx:PcbDraw [ master | ✚ 1 …2 ] ➭ ./pcbdraw.py ../PcbDraw-Lib/KiCAD-base/  out2.svg /Users/xxxxxxxx/EDA_Workspace/trial_git/ThermocoupleLogger.kicad_pcb
Namespace(board='/Users/johnpateman/EDA_Workspace/trial_git/ThermocoupleLogger.kicad_pcb', libraries=['../PcbDraw-Lib/KiCAD-base/'], list_components=False, no_drillholes=False, output='out2.svg', placeholder=False, remap=None, style=None)
Please ignore following debug output of KiCAD Python API
End of KiCAD debug output
/Volumes/SSD/workspace/osx-kicad-adam-head/kicad/common/lset.cpp(769): assert "unsigned( aLayer ) < PCB_LAYER_ID_COUNT" failed in ToLAYER_ID().
Traceback (most recent call last):
  File "./pcbdraw.py", line 463, in <module>
    wrapper.append(get_board_substrate(board, style, not args.no_drillholes))
  File "./pcbdraw.py", line 265, in get_board_substrate
    container.append(get_hole_mask(board))
  File "./pcbdraw.py", line 314, in get_hole_mask
    pos = pad.GetPosition()
AttributeError: 'SwigPyObject' object has no attribute 'GetPosition'
swig/python detected a memory leak of type 'DLIST_ITERATOR_WRAPPER< D_PAD > *', no destructor found.

How to install on windows 10 and kicad version 6.99 ?

How to install on windows 10 and kicad version 6.99 ?

i use

C:\Program Files\KiCad\6.0\bin>python.exe -m pip install PcbDraw
Collecting PcbDraw
Using cached PcbDraw-0.8.0-py3-none-any.whl (696 kB)
Collecting lxml
Using cached lxml-4.7.1-cp39-cp39-win_amd64.whl (3.7 MB)
Collecting pcbnewTransition
Using cached pcbnewTransition-0.2.0-py3-none-any.whl (4.3 kB)
Collecting mistune
Using cached mistune-2.0.0-py2.py3-none-any.whl (24 kB)
Collecting pyyaml
Using cached PyYAML-6.0-cp39-cp39-win_amd64.whl (151 kB)
Collecting wand
Using cached Wand-0.6.7-py2.py3-none-any.whl (139 kB)
Requirement already satisfied: numpy in c:\program files\kicad\6.0\bin\lib\site-packages (from PcbDraw) (1.21.5)
Collecting svgpathtools
Downloading svgpathtools-1.4.4-py2.py3-none-any.whl (66 kB)
|████████████████████████████████| 66 kB 929 kB/s
Collecting click
Downloading click-8.0.3-py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 2.2 MB/s
Collecting pybars3
Using cached pybars3-0.9.7.tar.gz (29 kB)
Preparing metadata (setup.py) ... done
Collecting colorama
Using cached colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting PyMeta3>=0.5.1
Using cached PyMeta3-0.5.1.tar.gz (29 kB)
Preparing metadata (setup.py) ... done
Collecting scipy
Downloading scipy-1.7.3-cp39-cp39-win_amd64.whl (34.3 MB)
|████████████████████████████████| 34.3 MB 6.4 MB/s
Collecting svgwrite
Downloading svgwrite-1.4.1-py3-none-any.whl (66 kB)
|████████████████████████████████| 66 kB 2.6 MB/s
Building wheels for collected packages: pybars3, PyMeta3
Building wheel for pybars3 (setup.py) ... done
Created wheel for pybars3: filename=pybars3-0.9.7-py3-none-any.whl size=14093 sha256=e093c67e743f47450ce03c11e51d1fc39d614c7886ea18be4e72cc0b01b6b322
Stored in directory: c:\users\xsoftz-pc\appdata\local\pip\cache\wheels\2c\63\6e\2fdd0384087778f0903c4dd80c8c0ee5355c551827428d7333
Building wheel for PyMeta3 (setup.py) ... done
Created wheel for PyMeta3: filename=PyMeta3-0.5.1-py3-none-any.whl size=16449 sha256=438891da1c672fe2a94a770624f33ebf6d3631c716ad34045daf61aafbb59ccb
Stored in directory: c:\users\xsoftz-pc\appdata\local\pip\cache\wheels\53\58\3f\4eadb07bcff9847154678b3cb722556834b477fb4b1cf1c2d0
Successfully built pybars3 PyMeta3
Installing collected packages: svgwrite, scipy, PyMeta3, colorama, wand, svgpathtools, pyyaml, pybars3, pcbnewTransition, mistune, lxml, click, PcbDraw
WARNING: The scripts pcbdraw.exe and populate.exe are installed in 'C:\Program Files\KiCad\6.0\bin\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed PcbDraw-0.8.0 PyMeta3-0.5.1 click-8.0.3 colorama-0.4.4 lxml-4.7.1 mistune-2.0.0 pcbnewTransition-0.2.0 pybars3-0.9.7 pyyaml-6.0 scipy-1.7.3 svgpathtools-1.4.4 svgwrite-1.4.1 wand-0.6.7

and run

C:\Program Files\KiCad\6.0\bin\Scripts>pcbdraw.exe
Traceback (most recent call last):
File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 197, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Program Files\KiCad\6.0\bin\Scripts\pcbdraw.exe_main
.py", line 4, in
File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\pcbdraw\pcbdraw.py", line 20, in
from pcbnewTransition import pcbnew, pcbnewVersion, isV6
ImportError: cannot import name 'pcbnewVersion' from 'pcbnewTransition' (C:\Program Files\KiCad\6.0\bin\Lib\site-packages\pcbnewTransition_init
.py)

not work

Missing 3rdparty directory resulting in ERROR: Could not install packages in Windows 10

Following the instructions to install in Windows 10 using pip install PcbDraw in the KiCad Command Prompt, I get the following:

ERROR: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified: 
'C:\\Users\\****\\Documents\\KiCad\\6.0\\3rdparty\\Python39'

It seems there is no 3rdparty directory in KiCad

Allow transformations of the origin element

PcbDraw currently cannot handle any transformation of the origin element. However such a functionality is highly desirable as the library maintainers don't have to care about the SVG structure.

To implement this functionality, it is necessary to collect transformation attributes of all parent elements and build a transformation matrix out of them. Then is is possible to transform the origin point.

Any help with this issue is appreciated!

Wrong rotation of pad with oval shape

PcbDraw generates pictures with a wrong rotation of pad with oval shape:
YellowMotorEncoder-front

In Kicad both of the holes have the same direction. But:

  • top has rotation = 0, x = 0.8, y = 5.5
  • bottom has rotation = -90, x = 5.5, y = 0.8
    image

Original file which was used as input for KiKit web page command:
YellowMotorEncoder_board.zip

Assert "process" failed in Pgm(). Segmentation fault (core dumped)

I am running kicad version 6.99.0_886_gd9d0fe97de-1 on linux and I get this error when trying to draw a board.

I tested it with a very simple board only containing a qfn package and it fails every time.

/builds/kicad/packaging/kicad-arch/kicad-arch-builder/kicad-nightly/src/kicad/pcbnew/pcbnew.cpp(319): assert "process" failed in Pgm().
Segmentation fault (core dumped)

Optimize the generated SVG

The generated SVG is currently quite messy. There are several things we should consider:

  • use [Scour] https://github.com/scour-project/scour to optimize the SVG (experiments show it can cut down the size to ~50%)
  • include components only once and then use the use tag
  • merge paths in SVGs generated by KiCAD to a single path (e.g., in the board outline)

Fails to generate PNGs

Hi,

I've tried to generate PNGs for a board but it keeps failing.
I've installed PcbDraw v0.6.1 using the command:

pip3 install PcbDraw

ImageMagick v6.9.7 is also installed.

When I run the command :

pcbdraw ./myboard.kicad_pcb ./front.png

The output is, (I've removed the warnings about missing footprint) :

Traceback (most recent call last):
File "/home/agambier/.local/bin/pcbdraw", line 11, in
sys.exit(main())
File "/home/agambier/.local/lib/python3.6/site-packages/pcbdraw/pcbdraw.py", line 811, in main
svg_to_bitmap(tmp_f.name, args.output, dpi=args.dpi)
File "/home/agambier/.local/lib/python3.6/site-packages/pcbdraw/pcbdraw.py", line 602, in svg_to_bitmap
image.read(filename=infile, resolution=dpi)
File "/home/agambier/.local/lib/python3.6/site-packages/wand/image.py", line 9668, in read
self.raise_exception()
File "/home/agambier/.local/lib/python3.6/site-packages/wand/resource.py", line 222, in raise_exception
raise e
wand.exceptions.FileOpenError: unable to open file `/tmp/magick-20982rDwer1eM32jv': No such file or directory @ error/constitute.c/ReadImage/544

AnyIdea what's missing on my system ?
thanks.

Problems generating PNGs

This is not PcbDraw fault, so take it as a warning, suggestion, whatever:
I was trying to generate PCB renders (no components) for the Spora project: Site, CI/CD example
The PCB is the size of a coin, and also has circular aspect.
When generating the SVG all goes OK (well I get the extra space around, but we know it)

pp

But when I ask for a PNG ...

spora-top

This is ImageMagick doing something wrong. I know it because I got the same using the convert command. May be this is a bug in the Debian testing package, not sure why it isn't using librsvg.
So I installed librsvg2-bin, the code I use as ImageMagick backend for conversions in my docker images, and used it directly:

rsvg-convert -d 600 -p 600 spora-top.svg > pp.png
convert -trim pp.png pp2.png

And voilà!

pp2

For JPG I used:

convert -trim pp.png -quality 85% pp2.jpg

pp2

I think this is a regression for you, if I'm right you switched from external commands to use ImageMagick as a module, but this seems to be more reliable (and a good way to get rid of the extra space while you solve it in the SVG ;-)

Fails to draw boards with circular edges

I was just trying out this cool tool and it works perfectly fine with boards that have straight edges. But when the board edge is curved, it crashes.

Here's the sample board I tried,

and here's the crash log

Traceback (most recent call last):
  File "/home/marcus/.local/bin/pcbdraw", line 11, in <module>
    sys.exit(main())
  File "/home/marcus/.local/lib/python3.6/site-packages/pcbdraw/pcbdraw.py", line 793, in main
    board_cont.append(get_board_substrate(board, style, not args.no_drillholes, args.back))
  File "/home/marcus/.local/lib/python3.6/site-packages/pcbdraw/pcbdraw.py", line 445, in get_board_substrate
    process(container, f, os.path.join(tmp, svg_file), colors, boardsize)
  File "/home/marcus/.local/lib/python3.6/site-packages/pcbdraw/pcbdraw.py", line 329, in process_board_substrate_base
    clipPath.append(get_board_polygon(extract_svg_content(read_svg_unique(source))))
  File "/home/marcus/.local/lib/python3.6/site-packages/pcbdraw/pcbdraw.py", line 284, in get_board_polygon
    outline = [elements[0]]
IndexError: list index out of range

Sphinx integration

A lot of us use sphinx for documentation, it would be cool if we add a direct integration to embed renders, ala populate. I am not sure if that should live here or in a separate repo. I do have interest in helping out with that but the amount of time I will be able to put in will depend on my workload with other projects. For now I am just opening to see if there is interest and to get initial feedback.

Problem trying to use populate.

Hi!,
I'm having some trouble trying to populate a board, when i run populate i get the following error:

(kicadenv) gonzalo@ubuntu:~/.virtualenvs/kicadenv/pcb_epi_tens$ populate fuente test
Warning: extra parameter 'template'
PcbDraw failed with code 1 and output:
b'Traceback (most recent call last):\n  File "/home/gonzalo/.virtualenvs/kicadenv/lib/python3.8/site-packages/pcbdraw/pc
bdraw.py", line 21, in <module>\n    from pcbdraw import __version__\n  File "/home/gonzalo/.virtualenvs/kicadenv/lib/py
thon3.8/site-packages/pcbdraw/pcbdraw.py", line 21, in <module>\n    from pcbdraw import __version__\nImportError: canno
t import name \'__version__\' from partially initialized module \'pcbdraw\' (most likely due to a circular import) (/hom
e/gonzalo/.virtualenvs/kicadenv/lib/python3.8/site-packages/pcbdraw/pcbdraw.py)\n'

I've used the example source_md.md file (renamed as "fuente") to generate the population, what i did was changing the route of the .kicad_pcb file, this is the file content:

---
img_name: img/populating_{}.png
type: md
board: PlacaEPI_TENS.kicad_pcb
libs: kicad-default
...

# Demo population manual

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Vestibulum fermentum tortor id mi. Nulla turpis magna, cursus sit amet, suscipit a, interdum id, felis.

- [[front | ]] This is the front side of the board we are populating
- [[back | ]] This is the back side of the board we are populating
- [[front | RV1, RV2 ]] First, populate RV1 and RV2. Basically, any description could be here.
- [[front | U2 ]] Let's populate U2!

You can put a paragraph of text between the population steps.

- [[back | R24 ]] We can also populate a component on the other side

And this is the end of the demo.

I've also generated the .svg files of the board using pcbdraw without any major issues, i've only got some warnings related to some missing libraries:

Warning: component 'R_0805_HandSoldering' for footprint 'R7' from library 'EMorales' was not found
Warning: component 'R_0805_HandSoldering' for footprint 'R6' from library 'EMorales' was not found
Warning: component 'R_0805_HandSoldering' for footprint 'R5' from library 'EMorales' was not found
Warning: component 'R_0805_HandSoldering' for footprint 'R4' from library 'EMorales' was not found
Warning: component 'R_0805_HandSoldering' for footprint 'R3' from library 'EMorales' was not found
Warning: component 'R_0805_HandSoldering' for footprint 'R2' from library 'EMorales' was not found
Warning: component 'R_0805_HandSoldering' for footprint 'R1' from library 'EMorales' was not found

Since i didn't need to plot the footprints or component's images, I´ve ignored these warnings. Could these warnings and the error I had when I tried to populate the board be related?.

Thank you for the great job you're doing with this project!
Gonzalo.-

Render back side

In the documentation that I'm doing, I need to be able to render the back side too. It would be nice if you could pass as an argument the face to render.
It is fine that the top face is rendered by default, but a --layer back, -b or something similar would be great.

Thanks.

Crash error

Using PcbDraw 0.8.0 with Linux Mint 20.2 Cinnamon I get a crash:

Traceback (most recent call last):
  File "/home/rsholmes/.local/bin/pcbdraw", line 8, in <module>
    sys.exit(main())
  File "/home/rsholmes/.local/lib/python3.8/site-packages/pcbdraw/pcbdraw.py", line 888, in main
    svg_to_bitmap(tmp_f.name, args.output, dpi=args.dpi)
  File "/home/rsholmes/.local/lib/python3.8/site-packages/pcbdraw/pcbdraw.py", line 629, in svg_to_bitmap
    image.read(filename=infile, resolution=dpi)
  File "/home/rsholmes/.local/lib/python3.8/site-packages/wand/image.py", line 9815, in read
    self.raise_exception()
  File "/home/rsholmes/.local/lib/python3.8/site-packages/wand/resource.py", line 222, in raise_exception
    raise e
wand.exceptions.FileOpenError: unable to open file `/tmp/magick-71547THq8ivVfSVJh': No such file or directory @ error/constitute.c/ReadImage/599

Permission denied wand.exceptions.BlobError: unable to open image on win32

On Windows 10 I get the following:

@echo off
call C:\Progra~1\KiCad\6.0\bin\kicad-cmd.bat
cd /d %~dp0
set out=.build
set pcb=nrfmicro.kicad_pcb
mkdir %out% >nul 2>&1

kikit fab jlcpcb --no-assembly --no-drc %pcb% %out%
pcbdraw --dpi 800 --filter "" %pcb% nrfmicro-devel-front.png

************************************
* KiCad 6.0 Command Prompt
************************************
You may now invoke python or pip targeting kicad's install
Traceback (most recent call last):
  File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\user\Documents\KiCad\6.0\3rdparty\Python39\Scripts\pcbdraw.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\Documents\KiCad\6.0\3rdparty\Python39\site-packages\pcbdraw\pcbdraw.py", line 960, in main
    svg_to_bitmap(tmp_f.name, args.output, dpi=args.dpi)
  File "C:\Users\user\Documents\KiCad\6.0\3rdparty\Python39\site-packages\pcbdraw\pcbdraw.py", line 670, in svg_to_bitmap
    image.read(filename=infile, resolution=dpi)
  File "C:\Users\user\Documents\KiCad\6.0\3rdparty\Python39\site-packages\wand\image.py", line 9815, in read
    self.raise_exception()
  File "C:\Users\user\Documents\KiCad\6.0\3rdparty\Python39\site-packages\wand\resource.py", line 222, in raise_exception
    raise e
wand.exceptions.BlobError: unable to open image 'C:\Users\user\AppData\Local\Temp\tmpb_e3sb2a.svg': Permission denied @ error/blob.c/OpenBlob/3527

Figures this is the issue with temp file on windows.

Patch:

--- ./pcbdraw.orig.py	2022-01-03 02:35:20.298551600 +0500
+++ ./pcbdraw.py	2022-01-03 02:33:43.296554700 +0500
@@ -952,12 +952,14 @@
         document.write(args.output)
         postprocess_svg(args.output, args.shrink)
     else:
-        with tempfile.NamedTemporaryFile(suffix=".svg") as tmp_f:
+        with tempfile.NamedTemporaryFile(suffix=".svg", delete=False) as tmp_f:
             document.write(tmp_f)
             tmp_f.flush()
             postprocess_svg(tmp_f.name, args.shrink)
             tmp_f.flush()
             svg_to_bitmap(tmp_f.name, args.output, dpi=args.dpi)
+            tmp_f.close()
+            os.unlink(tmp_f.name)
 
 if __name__ == '__main__':
     main()

Rare YAML parser

The current setup uses pyaml package, this is: Pretty YAML

This is a version of the popular PyYAML package ( PyYAML ) modified to emit prettier YAML.

But PcbDraw only parses YAML, never dumps it. So I don't see the point of using a rare dependency.

To illustrate my point, according to Debian voting system PyYAML has 26925 installations and 12527 votes. Which far more than what pyaml has: 58 installations and 4 votes.

I sugest replacing pyaml by pyyaml in setup.py

Fallback to 3D models?

This project is really awesome, unfortunately, the list of available models is lacking.

Maybe a long shot, but would it be possible to fallback to use the VRML 3D models already available for most parts?

E.g., there is https://github.com/tcr/vrml2svg to convert VRML into SVG (I didn't get it to work yet, but seems possible)

Makefile fails when dist directory missing or empty

When building package make tries to delete all files in dist/ directory. If the directory is not present (which is default after cloning) or it is empty then rm dist/* fails and so the make. Fix is remove the rm dist/* line or use -f.

PCBDraw does not account for the soldering paste

I want to know where I have soldering paste on the PCB. Kicad 3d view shows that, KicadScripts support that, how to do the same in PCBDraw? KicadScripts example output (note SMD pads are silver but the through-holes are golden):

nrfmicro-Front

Shared Object Import Error

Hi,

I've been trying to use your code on files made in nightly v5.99 20210126 release.

I'm running it in the docker container using https://github.com/INTI-CMNB/kicad_auto nightly image which I've manually updated to latest Kicad version (default is a year old release) but I keep getting these errors:

root@258b682816b4:/TEST_PCB_fiducial# PYTHONPATH=/usr/lib/kicad-nightly/lib/python3/dist-packages pcbdraw TEST_PCB_fiducial.kicad_pcb out.jpg
Traceback (most recent call last):
  File "/usr/bin/pcbdraw", line 11, in <module>
    load_entry_point('PcbDraw==0.6.0', 'console_scripts', 'pcbdraw')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 474, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2846, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/pcbdraw/pcbdraw.py", line 18, in <module>
    import pcbnew
  File "/usr/lib/kicad-nightly/lib/python3/dist-packages/pcbnew.py", line 38, in <module>
    import _pcbnew
ImportError: libkicad_3dsg.so.2.0.0: cannot open shared object file: No such file or directory

Any help would be appreciated as I've ran out of ideas for a fix :)

The file in questions exsists on the system here:
./usr/lib/kicad-nightly/lib/x86_64-linux-gnu/libkicad_3dsg.so.2.0.0
but Python can't find it for some reason.

Running the script without install is broken

I'll try to fix it, but right now I get:

$ pcbdraw/pcbdraw.py --version
Traceback (most recent call last):
  File "pcbdraw/pcbdraw.py", line 21, in <module>
    from pcbdraw import __version__
  File "/...absolute_path_in_my_system.../pcbdraw/pcbdraw.py", line 21, in <module>
    from pcbdraw import __version__
ImportError: cannot import name '__version__' from partially initialized module 'pcbdraw' (most likely due to a circular import) (/...absolute_path_in_my_system.../pcbdraw/pcbdraw.py)

Filter object is not subcriptable

Hi, I want to test your tool but I am receiving this error with filters. I don't know what to do. SDo you have any clue?

My PCB is a bord with many components. It is something unfinished. So, many components are out of the Edge.cut polygon.

I am using your SVG library and of course, the SVG library does not have all the components i need, but I think it is not necessary to put everything working. Am I right?

I am using Kicad 5.1.2, it uses Python 3, so I had to call python3 instead of python3 which is the system default. (This is why I renamed the script to pcbdraw_lheck.py

The version of your repo that I am using is this one (the last commit of the master branch)
image

➜ ./pcbdraw_lheck.py \
	--no-drillholes \
	~/Dropbox/kicad-plugins/PcbDraw-Lib/KiCAD-base \
	mangoh-red.kicad_pcb \
	mangoh-red.svg
Please ignore following debug output of KiCAD Python API
End of KiCAD debug output
Traceback (most recent call last):
  File "/home/lheck/Dropbox/kicad-plugins/PcbDraw/pcbdraw_lheck.py", line 642, in <module>
    board_cont.append(get_board_substrate(board, style, not args.no_drillholes, args.back))
  File "/home/lheck/Dropbox/kicad-plugins/PcbDraw/pcbdraw_lheck.py", line 380, in get_board_substrate
    process(container, f, os.path.join(tmp, svg_file), colors)
  File "/home/lheck/Dropbox/kicad-plugins/PcbDraw/pcbdraw_lheck.py", line 313, in process_board_substrate_base
    clipPath.append(get_board_polygon(extract_svg_content(read_svg_unique(source))))
  File "/home/lheck/Dropbox/kicad-plugins/PcbDraw/pcbdraw_lheck.py", line 263, in get_board_polygon
    elements.append(SvgPathItem(svg_element.attrib["d"]))
  File "/home/lheck/Dropbox/kicad-plugins/PcbDraw/pcbdraw_lheck.py", line 37, in __init__
    if path[0] != "M":
TypeError: 'filter' object is not subscriptable
make: *** [Makefile:58: svg] Error 1

Warning: component ... was not found

I am having a problem that no component is found.

$ pcbdraw voltLink.kicad_pcb test.png
------------------------------------------------------------------
Warning: component 'Fiducial_0.5mm_Mask1mm' for footprint 'FID1' from library 'Fiducial' was not found
Warning: component 'Fiducial_0.5mm_Mask1mm' for footprint 'FID2' from library 'Fiducial' was not found
Warning: component 'Fiducial_0.5mm_Mask1mm' for footprint 'FID3' from library 'Fiducial' was not found
Warning: component 'MountingHole_2.5mm_Pad' for footprint 'H1' from library 'MountingHole' was not found
Warning: component 'MountingHole_2.5mm_Pad' for footprint 'H2' from library 'MountingHole' was not found
Warning: component 'MountingHole_2.5mm_Pad' for footprint 'H3' from library 'MountingHole' was not found
Warning: component 'MountingHole_2.5mm_Pad' for footprint 'H4' from library 'MountingHole' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R10' from library 'Resistor_SMD' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C3' from library 'Capacitor_SMD' was not found
Warning: component 'D_0603_1608Metric_Pad1.05x0.95mm_HandSolder' for footprint 'D2' from library 'Diode_SMD' was not found
Warning: component 'D_SMA' for footprint 'D1' from library 'Diode_SMD' was not found
Warning: component 'SOT-363_SC-70-6' for footprint 'Q1' from library 'Package_TO_SOT_SMD' was not found
Warning: component 'QFN-24-1EP_4x4mm_P0.5mm_EP2.6x2.6mm' for footprint 'U2' from library 'Package_DFN_QFN' was not found
Warning: component 'SOT-363_SC-70-6' for footprint 'U1' from library 'Package_TO_SOT_SMD' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C2' from library 'Capacitor_SMD' was not found
Warning: component 'kibuzzard-61E57FAE' for footprint 'kibuzzard-61E57FAE' from library '' was not found
Warning: component 'USB_Micro-B_Molex-105017-0001' for footprint 'J3' from library 'myLib' was not found
Warning: component 'SolderJumper-2_P1.3mm_Bridged_RoundedPad1.0x1.5mm' for footprint 'JP2' from library 'Jumper' was not found
Warning: component 'PinHeader_1x08_P2.54mm_Vertical' for footprint 'J4' from library 'Connector_PinHeader_2.54mm' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R6' from library 'Resistor_SMD' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C7' from library 'Capacitor_SMD' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C9' from library 'Capacitor_SMD' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C10' from library 'Capacitor_SMD' was not found
Warning: component 'Fuse_1206_3216Metric_Pad1.42x1.75mm_HandSolder' for footprint 'F1' from library 'Fuse' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C5' from library 'Capacitor_SMD' was not found
Warning: component 'PinHeader_1x03_P2.54mm_Vertical' for footprint 'JP1' from library 'Connector_PinHeader_2.54mm' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C1' from library 'Capacitor_SMD' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C6' from library 'Capacitor_SMD' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R8' from library 'Resistor_SMD' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R3' from library 'Resistor_SMD' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R1' from library 'Resistor_SMD' was not found
Warning: component 'PinHeader_1x06_P2.54mm_Horizontal' for footprint 'J1' from library 'Connector_PinHeader_2.54mm' was not found
Warning: component 'SOT-23-5_HandSoldering' for footprint 'U3' from library 'Package_TO_SOT_SMD' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R9' from library 'Resistor_SMD' was not found
Warning: component 'JST_SH_BM06B-SRSS-TB_1x06-1MP_P1.00mm_Vertical' for footprint 'J2' from library 'Connector_JST' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R2' from library 'Resistor_SMD' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C8' from library 'Capacitor_SMD' was not found
Warning: component 'D_0603_1608Metric_Pad1.05x0.95mm_HandSolder' for footprint 'D3' from library 'Diode_SMD' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R5' from library 'Resistor_SMD' was not found
Warning: component 'PinHeader_1x08_P2.54mm_Vertical' for footprint 'J5' from library 'Connector_PinHeader_2.54mm' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C4' from library 'Capacitor_SMD' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R4' from library 'Resistor_SMD' was not found
Warning: component 'R_0603_1608Metric' for footprint 'R7' from library 'Resistor_SMD' was not found
Warning: component 'C_0603_1608Metric' for footprint 'C11' from library 'Capacitor_SMD' was not found

Running Arch Linux with pcbdraw-git package.
I tried installing it with pip, but then some components were populated and others weren't.

KiCad version: 6.0.1
PcbDraw version: 0.9.0-1
Python version: 3.10.1

Idea for a script

I have an idea for a script to generate SVG files easily. At least the initial version of them.

The script can use the 3d models of each footprint (.step files) to export a top view of the model in SVG format. It will be really good because it can generate a file for each footprint that misses the SVG view automatically. So, if the user wants something better he just has to open the file and improve the vector.

problem about absolute position

when I using pcbdraw, it told me that paths with absolute position are not supported ,how can i fix it

image

You seem to have fixed it ? 9a40720

why still show this error. thxxxxx

ruamel_yaml error

Hi,
The following command:

pinion generate -b sample.kicad_pcb ./

fails with error:

File "_ruamel_yaml.pyx", line 302, in _ruamel_yaml.CParser.__init__
TypeError: a string or stream input is required

Traceback:

Traceback (most recent call last):
File "/home/test/envs/pinion/bin/pinion", line 8, in <module>
sys.exit(cli())
File "/home/test/envs/pinion/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "/home/test/envs/pinion/lib/python3.9/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/home/test/envs/pinion/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/test/envs/pinion/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/test/envs/pinion/lib/python3.9/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/home/test/envs/pinion/lib/python3.9/site-packages/pinion/ui.py", line 83, in generate
generate(specification=yaml.load(specification),
File "/home/test/envs/pinion/lib/python3.9/site-packages/ruamel/yaml/main.py", line 432, in load
constructor, parser = self.get_constructor_parser(stream)
File "/home/test/envs/pinion/lib/python3.9/site-packages/ruamel/yaml/main.py", line 514, in get_constructor_parser
loader = XLoader(stream)
File "/home/test/envs/pinion/lib/python3.9/site-packages/ruamel/yaml/main.py", line 507, in __init__
CParser.__init__(selfx, stream)
File "_ruamel_yaml.pyx", line 302, in _ruamel_yaml.CParser.__init__
TypeError: a string or stream input is required

Environment:

KiCad   5.1.10

PcbDraw          0.8.0
pcbnewTransition 0.1.0
Pinion           0.2.0
PyYAML           5.4.1
ruamel.yaml      0.17.16
ruamel.yaml.clib 0.2.6

Any fix or workaround?

Thanks!

Remap not working

Nice work on this project.

I have an issue with the remap option.

I created a very basic remap file as follows:

{"Pin_Header_Straight_1x09_Pitch2.54mm": "Pin_Headers:Pin_Header_Straight_1x09.svg"}

I modified the python script slightly to dump out the dictionary contents and the path to the svg files as they are matched, see below.

The dictionary contents are:

(u'Pin_Header_Straight_1x09_Pitch2.54mm', u'Pin_Headers:Pin_Header_Straight_1x09.svg')

So the dictonary does contain the remap values. The get_model_file method does not seem to match the dictionary key value. For what reason I cannot determine Python is not a landguage I am that familiar with.

def get_model_file(paths, lib, name, ref, remapping):

I am running on debian with Python 3.5.3 Any ideas?

Namespace(board='/media/sf_Shares/UsbBleDongle/UsbBleDongle.kicad_pcb', libraries=['../PcbDraw-Lib/KiCAD-base'], list_components=False, no_drillholes=False, output='gen.svg', placeholder=False, remap='remap.json', style=None)
(u'Pin_Header_Straight_1x09_Pitch2.54mm', u'Pin_Headers:Pin_Header_Straight_1x09.svg')
Please ignore following debug output of KiCAD Python API
End of KiCAD debug output
../PcbDraw-Lib/KiCAD-base/Resistors_SMD/R_1206.svg
../PcbDraw-Lib/KiCAD-base/Footprints/RN4871.svg
Warning: component 'RN4871' from library 'Footprints' was not found
../PcbDraw-Lib/KiCAD-base/Capacitors_SMD/C_0805.svg
../PcbDraw-Lib/KiCAD-base/Capacitors_SMD/C_0805.svg
../PcbDraw-Lib/KiCAD-base/Capacitors_SMD/C_0805.svg
../PcbDraw-Lib/KiCAD-base/Capacitors_SMD/C_0805.svg
../PcbDraw-Lib/KiCAD-base/Capacitors_SMD/C_0805.svg
../PcbDraw-Lib/KiCAD-base/Diodes_SMD/D_0805.svg
Warning: component 'D_0805' from library 'Diodes_SMD' was not found
../PcbDraw-Lib/KiCAD-base/Diodes_SMD/D_0805.svg
Warning: component 'D_0805' from library 'Diodes_SMD' was not found
../PcbDraw-Lib/KiCAD-base/Resistors_SMD/R_0805.svg
../PcbDraw-Lib/KiCAD-base/Resistors_SMD/R_0805.svg
../PcbDraw-Lib/KiCAD-base/Resistors_SMD/R_0805.svg
../PcbDraw-Lib/KiCAD-base/Resistors_SMD/R_0805.svg
../PcbDraw-Lib/KiCAD-base/Capacitors_SMD/C_0805.svg
../PcbDraw-Lib/KiCAD-base/Capacitors_SMD/C_0805.svg
../PcbDraw-Lib/KiCAD-base/Capacitors_SMD/C_0805.svg
../PcbDraw-Lib/KiCAD-base/Pin_Headers/Pin_Header_Straight_1x09_Pitch2.54mm.svg
Warning: component 'Pin_Header_Straight_1x09_Pitch2.54mm' from library 'Pin_Headers' was not found
../PcbDraw-Lib/KiCAD-base/Footprints/USB_CONN_MOLEX_48037-2200.svg
Warning: component 'USB_CONN_MOLEX_48037-2200' from library 'Footprints' was not found
../PcbDraw-Lib/KiCAD-base/Footprints/R-PDSO-N5.svg
Warning: component 'R-PDSO-N5' from library 'Footprints' was not found
../PcbDraw-Lib/KiCAD-base/Footprints/QFN-24_1EP_4x4mm_Pitch0.5mm.svg
Warning: component 'QFN-24_1EP_4x4mm_Pitch0.5mm' from library 'Footprints' was not found

Remapping pcb footprint <-> pcbdraw footprints instead of reference <-> pcbdraw footprint

For now I'm forced to list every footprint on the pcb (30 resistors, 30 capacitors) with a remapping for each. That's a bit error-prone.

What I have in mind is something like :

{
    "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder": "Resistors_SMD:R_0805_2012Metric",
    "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder": "Capacitors_SMD:C_0805_2012Metric"
}

That could be named as a "compatibility table" between PCBnew lib and PCBDraw lib. That way, a remapping can still be used.

Maybe that could support globs ?

Problems using `--shrink`

I tried --shrink on the following PCB: spora using:

pcbdraw --shrink 0 spora.kicad_pcb 2.png

And it crashed:

Traceback (most recent call last):
  File "/usr/bin/pcbdraw", line 33, in <module>
    sys.exit(load_entry_point('PcbDraw==0.9.0', 'console_scripts', 'pcbdraw')())
  File "/usr/lib/python3/dist-packages/pcbdraw/pcbdraw.py", line 988, in main
    postprocess_svg(tmp_f.name, args.shrink)
  File "/usr/lib/python3/dist-packages/pcbdraw/pcbdraw.py", line 824, in postprocess_svg
    shrink_svg(svgfilepath, shrinkBorder)
  File "/usr/lib/python3/dist-packages/pcbdraw/pcbdraw.py", line 778, in shrink_svg
    paths = document.paths()
  File "/usr/lib/python3/dist-packages/svgpathtools/document.py", line 261, in paths
    return flattened_paths(self.tree.getroot(), group_filter,
  File "/usr/lib/python3/dist-packages/svgpathtools/document.py", line 143, in flattened_paths
    path = transform(parse_path(converter(path_elem)), path_tf)
  File "/usr/lib/python3/dist-packages/svgpathtools/path.py", line 309, in transform
    return transform_segments_together(curve, transformation)
  File "/usr/lib/python3/dist-packages/svgpathtools/path.py", line 191, in transform_segments_together
    transformed_segs = [transformation(seg) for seg in path]
  File "/usr/lib/python3/dist-packages/svgpathtools/path.py", line 191, in <listcomp>
    transformed_segs = [transformation(seg) for seg in path]
  File "/usr/lib/python3/dist-packages/svgpathtools/path.py", line 308, in <lambda>
    transformation = lambda seg: transform(seg, tf)
  File "/usr/lib/python3/dist-packages/svgpathtools/path.py", line 339, in transform
    return Arc(new_start, radius=new_radius, rotation=curve.rotation + rot,
  File "/usr/lib/python3/dist-packages/svgpathtools/path.py", line 1448, in __init__
    self._parameterize()
  File "/usr/lib/python3/dist-packages/svgpathtools/path.py", line 1503, in _parameterize
    raise ValueError("No such elliptic arc exists.")

BTW: the svgpathtool dependency pulls at least 64 MB of stuff, I think this is an overkill to implement --shrink

Live examples

It would be great to host the live examples on gitlab pages or similar :-)

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.