Anyhow, for the time being I’ll probably need to pull out each layer one by one in black&white and compose it over each other with some 3rd party tool/scripting. Any idea what workflow is best for this? Output from the plot API is svg, pdf, gerber and ps it seems.
So back to plan B - any workflow for overlaying several svgs/pdfs/postscripts/gerbers and getting them onto a single page via an automated process? Please.
OK, got nowhere. Installing breaks down when I’m chasing the 3rd or 4th dependency and I just don’t have the time for that now.
Different approach.
The colors that are being loaded when KiCAD is being run are the ones that count… so, nothing more simple than just having a copy of the pcbnew file that is located here in Win7:
C:\Users\JohnDoe\AppData\Roaming\kicad\pcbnew
And modifying the layer colors how I need them for the grey toned print out.
Once I’m done producing the documentation for a particular board I just swap the pcbnew file back in with the real colors for the layers and can keep on working.
Rather crude, but I can use the native print facility from within KiCAD to get the stuff done.
According the kicad’s scripting documentationSetColor method expects an argument in the type of EDA_COLOR_T which I couldn’t find a definition in the python bindings file (pcbnew.py).
But EDA_COLOR_T is an enum as defined here. I got the number ‘14’ for ‘CYAN’ color by simply counting. In C/C++ you can pass an integer instead of an enum value, so it may work in python bindings as well.
Looking at the pcbnew API and searching within the different xy_PLOTTER’s (PDF, POST, SVG, GERBER) only gerber seems to have this feature.
It’s missing in PDF_PLOTTER and in SVG_PLOTTER doesn’t work (as I expect it).
Anyhow… the workaround from above with the init file and restarting KiCAD might work on-the-fly when I look at this pcbnew.COLORS_DESIGN_SETTINGS class here:
I would then adapt the plot script to read out the current layer colors and swap them for the ones I desire, print and swap them back - no need to restart KiCAD and mocking around with init files, or?
Well, I’ll play with it tonight if I have some time to spare…
OK, for anyone who wants grey-scale prints of boards for assembling them by hand, here are my current pcbnew color settings for the layers to get some decent print out on a black and white laser printer:
These settings reside in an ini file called pcbnew (in the same folder are other settings files for eeschema or kicad etc…). Under Windows 7 it’s located here:
C:\Users\JohnDoe\AppData\Roaming\kicad\pcbnew
Create another file with extension .PRINT (copy pcbnew) and replace above lines in there.
Procedure if you want to print something with those color settings:
quit KiCAD completely
swap pcbnew ini with pcbnew.PRINT ini by doing this:
– 1st rename ‘normal’ pcbnew into pcbnew.LAYOUT
– 2nd rename pcbnew.PRINT into pcbnew
start KiCAD/pcbnew
open print dialog and set it to Print Mode [Color]
print
quit pcbnew/KiCAD and revert the pcbnew ini file swap from above
I’ll see if I can whip up some script that would do this, but it will take some time. Maybe someone else can create a script that swaps layer colors for printing and reverses those settings to the layout colors once printing is done?
PS: I know that the XH connector symbols are the wrong way around and some bottom devices outlines show up, still working on it (have 1/3rd of my local lib adapted so far phew).
PPS: I have REF** on Eco1 and VAL** as well as the device outlines on F.Fab. There is information on silkscreen, but I don’t print that. Problem with REF being on a non-Top/Bottom layer… both top and bottom devices REF fields are visible on the print. If you stick with KiCAD library ‘rules’ you shouldn’t have this problem though, just print the silkscreen layers to get the REF fields for the correct side.
Hello Joan,
I’ve read a number of post and it seems you have a good understanding for the python interface to Kicad. I’ve written a few python script but mostly for educational purposes. I’m trying to learn how to do replicate some of the kicad dialog box behaviors in python. Since this post had python and plotting, I’ll explain what I would like to learn to do. I would like to plot gerber and pdf files via a python script. The main purpose is to generate these files without forgetting one of the options. (back in my VLSI days we loved to call this the “make chip” script) For example, when I plot gerbers, I turn off all the options except “use aux axis”, I select the cooper layers, paste, sliks, masks, and edge. When I plot pdfs, I turn on a number of the options, turn off the cooper layers, paste, mask, and edges. Then I turn on the fab layers, I mirror plot the back layers, so this translates into another set of options and layers. You would be amazed how much grief this causes keeping track of what I’ve done and if I did it right (so much validations…). In addition, there are things like setting pad mask clearances that need to be checked before generating the gerbers. But that’s later, I think I might be able to figure out how to do this if I can get my head around a script that will generate the plots. I think if I can see how to do the plots, I’m 99% sure I’ll become dangerous. So, here’s the issue, I really don’t even know how to find the functions (def) to call and what parameters to pass, or even how to init the environment, like if I need to load the board file for example if I’m using the built in python IDE… Sad I know. I just can’t find an example that does this… Help?
So, I found http://ci.kicad.org/job/kicad-doxygen/ws/build/pcbnew/doxygen-python/html/annotated.html and PCB_PLOT_PARAMS which looks like I can set many of the plot options. I’ve been playing with this and it seem I’m a bit more dangerous than before. Still can’t figure out what uses these params and writes a gerber file. The GERBER_PLOTTER class looks like it deals with converting shapes and whatnots, so I don’t think this is the correct path. I’m going to start looking at the C code, maybe something will open my eyes…
No, it didn’t work for me with the python interface :_/
I’m trying to have a resulting DXF file with BLUE borders and all the following attempts failed, defaulting back to BLACK for lines:
# Do the BRD edges in blue, compatible with Ponoko.com laser engraving service:
# https://ponoko.zendesk.com/hc/en-us/community/posts/210090388-File-won-t-upload-and-says-Oops-Please-Check-Your-Stroke-Colors-
# Blue for cutting, Red for line engraving
#popt.SetColor(COLOR4D.BLACK)
#
# BLUE in https://github.com/KiCad/kicad-source-mirror/blob/d7bf44eee0a1ac4cf9a852d66c4ed65fff9cb788/include/colors.h
# According to https://forum.kicad.info/t/plot-scripting-api-color-choice-for-layers/2074/4
# https://www.ponoko.com/starter-kits/inkscape#inkscape_section_6_1
# "And set the stroke color to blue with the 'Stroke paint' RGBA values of 0, 0, 255, 255"
popt.SetColor(COLOR4D(0, 0, 255, 255))
#print(dir(COLOR4D))
#print(dir(popt.SetColor))
#popt.SetColor(COLOR4D.SetToNearestLegacyColor(COLOR4D.EDA_COLOR_T('BLUE')))
#popt.SetColor(ColorGetName(12))
#popt.SetColor(YELLOW)
Please let me know if it’s possible at all or those color settings have nothing to do with DXF export :-S
You are not alone (see https://stackoverflow.com/questions/43645628/how-to-plot-colored-output-from-pcbnew-via-python-scripting) and I couldn’t get this to work either.
I have tried substituting colours within the generated svg but you can end up with problems of islands not being coloured (I wanted to produce a negative image - with the layer contents coloured and the background black - I think you may need to do some tweaking of the ‘evenodd’ descriptor to get this to work within the svg as swapping, say black for red and then white for black in the svg didn’t work well). I ended up producing my svgs and post-processing them with image magick. (See https://github.com/Gasman2014/KiCad-Diff - a work in progress!)
Even the author of OpenFixture went through the same struggle and gave up in favor of InkScape manual fixes (importing the DXF, changing color, exporting to SVG, submitting to Ponoko):