Skip to content

sebastianhuus/kicad-export-with-fill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KiCad PDF Export with Zone Fill

A CLI tool that exports KiCad PCB files to PDF after filling all zones.

This solves the limitation in KiCad 9.x where kicad-cli pcb export pdf does not fill zones before exporting. (The --check-zones flag was added in KiCad 10.)

Requirements

  • KiCad 9.x installed (uses KiCad's Python scripting API)
  • macOS or Linux

Installation

# Clone or download, then:
./install.sh

# To uninstall:
./uninstall.sh

The install script creates a symlink in ~/.local/bin (or /usr/local/bin if writable).

If ~/.local/bin is not in your PATH, add it:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Usage

# Basic usage
./kicad-export-pdf board.kicad_pcb -o output.pdf

# Specific layers
./kicad-export-pdf board.kicad_pcb -o output.pdf --layers F.Cu,B.Cu

# Use a preset
./kicad-export-pdf board.kicad_pcb -o output.pdf --layers outer

# Skip zone filling (if already filled)
./kicad-export-pdf board.kicad_pcb -o output.pdf --no-fill

# Verbose output
./kicad-export-pdf board.kicad_pcb -o output.pdf -v

Layer Presets

Preset Layers
copper F.Cu, B.Cu
outer F.Cu, B.Cu, F.SilkS, B.SilkS, F.Mask, B.Mask, Edge.Cuts
fab F.Fab, B.Fab, Edge.Cuts
assembly F.Fab, B.Fab, F.SilkS, B.SilkS, Edge.Cuts
all-copper All enabled copper layers

Options

positional arguments:
  input                 Input .kicad_pcb file

options:
  -h, --help            show this help message and exit
  -o, --output OUTPUT   Output PDF file path (required)
  -l, --layers LAYERS   Comma-separated layer names or preset
  --no-fill             Skip zone filling
  --mirror              Mirror the output
  --negative            Negative plot
  --bw                  Black and white output
  --no-values           Exclude component values
  --no-refs             Exclude reference designators
  --frame               Include border and title block
  -v, --verbose         Verbose output

Direct Python Usage

If the wrapper script doesn't find KiCad's Python, you can run directly:

# macOS
/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/Current/bin/python3 \
    kicad_export_pdf.py board.kicad_pcb -o output.pdf

# Or set KICAD_PYTHON
export KICAD_PYTHON=/path/to/kicad/python3
./kicad-export-pdf board.kicad_pcb -o output.pdf

Integration with Build Scripts

#!/bin/bash
# Example: export all PCBs in a directory

EXPORT_SCRIPT="./kicad-export-pdf"

for pcb in pcbs/*.kicad_pcb; do
    name=$(basename "$pcb" .kicad_pcb)
    $EXPORT_SCRIPT "$pcb" -o "output/${name}.pdf" --layers outer -v
done

How It Works

  1. Loads the PCB using KiCad's pcbnew Python module
  2. Creates a ZONE_FILLER and fills all zones
  3. Uses PLOT_CONTROLLER to export to PDF
  4. The filled zones are included in the PDF output

The zones are filled in memory only - the original .kicad_pcb file is not modified.

License

MIT

About

Small hack for KiCad Cli in V9 to enable Zone Fill on exported PCB designs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors