PcbDraw – KiCAD board into a nice looking 2D drawing

This small Python script takes a Ki CAD board (.ki cad_ 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 pin out diagrams for your project. These diagrams are much easier to read than a labeled photo of a physical board or an actual Ki CAD design.
You and your users will love them!

Dependencies

This script requires the pcbnew Python module (should come with KiCAD), the argparse and lxlml modules. No other dependencies are needed.


PcbDraw also needs a module library to work. This library is maintained as a separate repository: PcbDraw-Lib.

Usage

Usage of PcbDraw is simple, just run:

./pcbdraw.py <libraries> <output_ file> <input_ file>
  • libraries is a comma separated list of paths to directories containing module libraries. Modules are component footprints in SVG format.
  • output_ file is a path to an output SVG file
  • input_ file is a path to an *.ki cad_ pcb file

The script will output several debug messages of Ki CAD Python API you can ignore. I haven’t found a way to disable them. If there is a missing module in the libraries, the script will output warning.
There are several options for the script:

  • --style=<JSON_ file> specifies color theme for the board. Default is a green board, other styles can be found in the styles directories.
  • --list-components prints a list of all components from the front side of PCB. Doesn’t produce drawing.
  • --placeholder shows a red square in the drawing for missing modules.
  • --remap takes a path to a JSON file containing a dictionary from component references to alternative modules to change a module for given component. This allows you to e.g. choose different colors for LEDs without a need to change original board and create new packages for different colors. Format of dictionary entry is "<ref>": "<library>:<module>" – e.g. "PHOTO1": "Resistors:R_PHOTO_7mm".
  • --no-drill holes do not make the drill holes transparent.

Writing Custom Styles

Style is a JSON file contain color definitions for the board substrate (they don’t have any effect on modules):

{
    "copper": "#417e5a",
    "board": "#4ca06c",
    "silk": "#f0f0f0",
    "pads": "#b5ae30",
    "outline": "#000000"
}

Colors are in HEX format, names of the colors should be self descriptive.

Module Library

Library is a collection of SVG files each containing one drawing of a component. The library structure follows Ki CAD library structure – each footprint (module) is a separate file placed in directories representing libraries.
It is also possible to have multiple libraries with different component style.
Read More: PcbDraw – KiCAD board into a nice looking 2D drawing

Leave a Comment

Your email address will not be published. Required fields are marked *