A script to generate KiCad board outlines

PCB fabricators require a board outline on the `Edge.Cuts` layer to specify the board size and shape. While drawing the board outline in the PCB editor is straightforward and uses the standard line and shape drawing tools, it is convenient to retain standardized board outlines and related parts, such as fasteners, as reusable footprints. During the board layout process, you can simply plop a board outline, along with perfectly-placed mounting holes into the editor and you can concentrate on the placing components and routing. Also, having a standard library of board outlines gives you a predictable set of size choices for enclosures and for ordering SMD stencils.

This is why I created KiCadBoardOutlineGenerator, a script to generate board outlines from dimensions you specify.

The script as a number of options - height and width in mm (floating point values are accepted), rounded or squared corners, optional mounting holes at the corners - either M2 or M3.

To run the script:

python3 generate_board_outline.py WIDTH HEIGHT HOLE_TYPE [-o OUTPUT_DIR] [--corner-radius [MM]] [--group-elements]

where the options are defined as follows:

  • WIDTH: board width in mm (X dimension)
  • HEIGHT: board height in mm (Y dimension)
  • HOLE_TYPE: one of:
    • M2 (four M2 corner holes)
    • M3 (four M3 corner holes)
    • none (no holes)
  • -o / --output-dir (optional): output directory
    • If omitted, defaults to: pcb/libraries/footprints/Ojisan-BoardOutlines.pretty
  • --corner-radius [MM] (optional): enable rounded corners
    • If MM is provided, it sets the rounded-corner radius in mm
    • If MM is omitted, the default radius is 2.0 mm
    • If --corner-radius is not provided, corners are sharp (plain rectangle)
    • Backwards compatibility: --rounded is accepted as a deprecated alias for --corner-radius (default radius)
  • --group-elements (optional): wrap generated primitives in a KiCad (group ...) block

I have made the script open-source and available on GitHub. You will need to alter the default path of course.