Files
kicad2gcode/export.sh
T
2026-09-05 20:01:30 +02:00

51 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
GERBERS_DIR="gerbers"
GCODE_DIR="gcode"
usage() {
echo "Usage: $0 <kicad_pcb_file>"
exit 1
}
PCB_FILE="$1"
PCB_FILE_PREFIX="$(basename "$PCB_FILE" .kicad_pcb)"
mkdir -p "$GERBERS_DIR"
mkdir -p "$GCODE_DIR"
# Export drill, outline, front and back layers as gerber files.
echo "Exporting gerbers..."
kicad-cli pcb export drill --generate-map -o "$GERBERS_DIR" "$PCB_FILE"
kicad-cli pcb export gerbers -o "$GERBERS_DIR" -l Edge.Cuts "$PCB_FILE"
kicad-cli pcb export gerbers -o "$GERBERS_DIR" -l F.Cu "$PCB_FILE"
kicad-cli pcb export gerbers -o "$GERBERS_DIR" -l B.Cu "$PCB_FILE"
echo "Exporting SVGs..."
kicad-cli pcb export svg -o "$GERBERS_DIR" -l B.Mask \
--mode-multi --page-size-mode 1 --black-and-white \
--drill-shape-opt 0 --exclude-drawing-sheet "$PCB_FILE"
kicad-cli pcb export svg -o "$GERBERS_DIR" -l F.SilkS \
--negative \
--mode-multi --page-size-mode 1 --black-and-white \
--drill-shape-opt 0 --exclude-drawing-sheet "$PCB_FILE"
# kicad-cli pcb export svg -o "$GERBERS_DIR" -l Edge.Cuts \
# --mode-multi --page-size-mode 1 --black-and-white \
# --drill-shape-opt 0 --exclude-drawing-sheet "$PCB_FILE"
echo "Exporting Gcode for drilling, outline and isolation traces routing..."
docker run --rm -it \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/data" \
ptodorov/pcb2gcode \
--config millproject \
--output-dir "$GCODE_DIR" \
--front "$GERBERS_DIR/$PCB_FILE_PREFIX-F_Cu.gtl" \
--back "$GERBERS_DIR/$PCB_FILE_PREFIX-B_Cu.gbl" \
--drill "$GERBERS_DIR/$PCB_FILE_PREFIX.drl" \
--outline "$GERBERS_DIR/$PCB_FILE_PREFIX-Edge_Cuts.gm1"