|
|
||
|---|---|---|
| .github/workflows | ||
| debian | ||
| docs/samples | ||
| kiplot | ||
| src | ||
| tests | ||
| .flake8 | ||
| .gitignore | ||
| LICENSE | ||
| MANIFEST.in | ||
| Makefile | ||
| README.md | ||
| setup.cfg | ||
| setup.py | ||
README.md
KiPlot
KiPlot is a program which helps you to plot your KiCad PCBs to output formats easily, repeatable, and most of all, scriptably. This means you can use a Makefile to export your KiCad PCBs just as needed.
For example, it's common that you might want for each board rev:
- Check ERC/DRC one last time (using KiCad Automation Scripts)
- Gerbers, drills and drill maps for a fab in their favourite format
- Fab docs for the assembler
- Pick and place files
You want to do this in a one-touch way, and make sure everything you need to do so it securely saved in version control, not on the back of an old datasheet.
KiPlot lets you do this.
As a side effect of providing a scriptable plot driver for KiCad, KiPlot also allows functional testing of KiCad plot functions, which would otherwise be somewhat unwieldy to write.
The configuration file
Kiplot uses a configuration file where you can specify what outputs to generate. By default you'll generate all of them, but you can specify which ones from the command line.
The configuration file should be named *.kiplot.yaml. The format used is YAML. This is basically a text file with some structure.
The header
All configuration files must start with:
kiplot:
version: 1
This tells to Kiplot that this file is using version 1 of the format.
The preflight section
This section is used to specify tasks that will executed before generating any output. The available tasks are:
run_ercTo run the ERC (Electrical Rules Check). To ensure the schematic is electrically correct.run_drcTo run the DRC (Distance Rules Check). To ensure we have a valid PCB.update_xmlTo update the XML version of the BoM (Bill of Materials). To ensure our generated BoM is up to date.
The run_drc command has the following options:
check_zone_fillsEvery time we run the DRC the zones are filled again. This option saves the PCB to disk updating the zones.ignore_unconnectedIgnores the unconnected nets. Useful if you didn't finish the routing.
Here is an example of a preflight section:
preflight:
run_erc: true
update_xml: true
run_drc: true
check_zone_fills: true
ignore_unconnected: false
The outputs section
In this section you put all the things that you want to generate. This section contains one or more outputs. Each output contain the following data:
namea name so you can easily identify it.commenta short description of this output.typeselects which type of output will be generated. Examples are gerbers, drill files and pick & place filesdiris the directory where this output will be stored.optionscontains one or more options to configure this output.layersa list of layers used for this output. Not all outputs needs this subsection.
The available values for type are:
- Plot formats:
gerberthe gerbers for fabrication.pspostscript plothpglformat for laser printerssvgscalable vector graphicspdfportable document formatdxfmechanical CAD format
- Drill formats:
excellondata for the drilling machinegerb_drilldrilling positions in a gerber file
- Pick & place
positionof the components for the pick & place machine
- Documentation
pdf_sch_printschematic in PDF formatpdf_pcb_printPDF file containing one or more layer and the page frame
- Bill of Materials
kibomBoM in HTML or CSV format generated by KiBoMibomInteractive HTML BoM generated by InteractiveHtmlBom
Here is an example of a configuration file to generate the gerbers for the top and bottom layers:
kiplot:
version: 1
preflight:
run_drc: true
outputs:
- name: 'gerbers'
comment: "Gerbers for the board house"
type: gerber
dir: gerberdir
options:
# generic layer options
exclude_edge_layer: false
exclude_pads_from_silkscreen: false
plot_sheet_reference: false
plot_footprint_refs: true
plot_footprint_values: true
force_plot_invisible_refs_vals: false
tent_vias: true
check_zone_fills: true
line_width: 0.15
# gerber options
use_aux_axis_as_origin: false
subtract_mask_from_silk: true
use_protel_extensions: false
gerber_precision: 4.5
create_gerber_job_file: true
use_gerber_x2_attributes: true
use_gerber_net_attributes: false
layers:
- layer: F.Cu
suffix: F_Cu
- layer: B.Cu
suffix: B_Cu
Most options are the same you'll find in the KiCad dialogs.
General options for plot formats
exclude_edge_layerdo not include the PCB edge layerexclude_pads_from_silkscreendo not plot the component pads in the silk screenplot_sheet_referencecurrently without effectplot_footprint_refsinclude the footprint referencesplot_footprint_valuesinclude the footprint valuesforce_plot_invisible_refs_valsinclude references and values even when they are marked as invisibletent_viascover the viascheck_zone_fillscurrently without effect
Note that each layer is generated in a separated file.
Gerber options
line_widthfor objects without width (floating point value in mm)use_aux_axis_as_originuse the auxiliar axis as origin for coordinatessubtract_mask_from_silksubstract the solder mask from the silk screenuse_protel_extensionsuse legacy Protel file extensionsgerber_precisionthis the gerber coordinate format, can be 4.5 or 4.6create_gerber_job_filecreates a file with information about all the generated gerbers. You can use it in gerbview to load all gerbers at once.use_gerber_x2_attributesuse the extended X2 formatuse_gerber_net_attributesinclude netlist metadata
PS options
line_widthfor objects without width (floating point value in mm)mirror_plotplot mirrorednegative_plotinvert black and whitescalingscale factordrill_markswhat to use to indicate the drill places, can benone,smallorfull(for real scale)scale_adjust_xfine grain adjust for the X scale (floating point multiplier)scale_adjust_yfine grain adjust for the Y scale (floating point multiplier)a4_outputforce A4 paper size
SVG and PDF options
line_widthfor objects without width (floating point value in mm)mirror_plotplot mirrorednegative_plotinvert black and whitedrill_markswhat to use to indicate the drill places, can benone,smallorfull(for real scale)
HPGL options
mirror_plotplot mirroredscalingscale factordrill_markswhat to use to indicate the drill places, can benone,smallorfull(for real scale)pen_widthdefault trace width
DXF options
drill_markswhat to use to indicate the drill places, can benone,smallorfull(for real scale)polygon_modeplot using the contour, instead of the center line
General drill options
use_aux_axis_as_originuse the auxiliar axis as origin for coordinatesmapthis is an optional subsection to indicate the format for a graphical drill map. The valid formats arehpgl,ps,gerber,dxf,svgandpdf. Example:
map:
type: 'pdf'
reportthis is an optional subsection to indicate the name of the drill report, example:
report:
filename: 'Project-drl.rpt'
Excellon drill options
metric_unitsuse metric units instead of inches.pth_and_npth_single_filegenerate one file for both, plated holes and non-plated holes, instead of two separated files.minimal_headeruse a minimal header in the filemirror_y_axisinvert the Y axis
Position options
formatcan beasciiorcsv.unitscan bemillimetersorinches.separate_files_for_front_and_backgenerate two separated files, one for the top and another for the bottom.only_smdonly include the surface mount components.
pdf_pcb_print options
output_namefilename for the output PDF
KiBoM options
formatcan behtmlorcsv.
IBoM options
blacklistregular expression for the components to exclude (using the Config field)name_formatformat of the output name, example:%f_%r_iBoMwill generate a file with revision and _iBoM.
pdf_sch_print options
outputfilename for the output PDF
Using KiPlot
If the current directory contains only one PCB file and only one configuration file (named *.kiplot.yaml)
you can just call kiplot. No arguments needed. The tool will figure out which files to use.
If more than one file is found in the current directory kiplot will use the first found and issue a
warning. If you need to use other file just tell it explicitly:
kiplot -b PCB_FILE.kicad_pcb -c CONFIG.kiplot.yaml
A simple target can be added to your makefile, so you can just run
make pcb_files or integrate into your current build process.
pcb_files:
kiplot -b $(PCB) -c $(KIPLOT_CFG)
If you need to supress messages use --quiet or -q and if you need to get more informatio about
what's going on use --verbose or -v.
If you want to generate only some of the outputs use:
kiplot OUTPUT_1 OUTPUT_2
If you want to generate all outputs with some exceptions use:
kiplot --invert-sel OUTPUT_1 OUTPUT_2
If you want to skip the DRC and ERC use:
kiplot --skip-pre run_erc,run_drc
If you want to skip all the preflight tasks use:
kiplot --skip-pre all
All outputs are generated using the current directory as base. If you want to use another directory as base use:
kiplot --out-dir OTHER_PLACE
If you want to list the available outputs defined in the configuration file use:
kiplot --list
Installing
Dependencies
- For ERC, DRC, BoM XML update and PCB/SCH print install KiCad Automation Scripts
- For HTML/CSV BoM install KiBoM
- For interactive BoM install InteractiveHtmlBom
Installation on Ubuntu/Debian:
Get the Debian package from the releases section and run:
sudo apt install ./kiplot.inti-cmnb_*_all.deb
Installation on other targets
- Install KiCad 5.x
- Install Python 3.5 or newer
- Install the Python Yaml module
- Run the script src/kiplot
Using for CI/CD
When using a GitHub or GitLab repo you can use KiPlot to generate all the needed stuff each time you commit a change to the schematic and/or PCB file.
Examples of how to do it can be found here for GitHub and here for GitLab.
In order to run KiPlot on these environments you need a lot of software installed. The usual mechanism to achieve this is using docker. Docker images containing KiPlot, all the supporting scripts and a corresponding KiCad can be found at Docker Hub as setsoft/kicad_auto:latest. This image is based on setsoft/kicad_debian:latest, containing KiCad on Debian GNU/Linux.
For more information about the docker images visit kicad_debian and kicad_auto.