Skip to content

Repository files navigation

KiCAM

KiCad → CircuitCAM: convert a modern KiCad fabrication set (Gerber RS-274X + Excellon drills) into the legacy format that CircuitCAM 3.x understands, to mill PCBs on an LPKF ProtoMat (tested on a ProtoMat C60) — all in one shot.

CircuitCAM 3 predates the extended RS-274X features KiCad relies on today. In particular it cannot read embedded aperture definitions or aperture macros (%AM — the RoundRect pads KiCad emits by default), so importing a modern Gerber silently drops most SMD pads. This tool bridges that 20-year gap.

Features

  • One-shot project conversion: add all your Gerber layers (top/bottom copper, edge cuts, ...) and the PTH/NPTH drill files, press Convert.
  • Unified aperture wheel: one .whl for every layer. D-codes are renumbered into a single global sequence (KiCad restarts at D10 in every file with different definitions).
  • Full aperture support for modern KiCad (v5–v9):
    • C / R / O apertures become native wheel entries (Circle, Rectangle, Finger) with the Mode keywords CircuitCAM's import templates require;
    • RoundRect, HorizOval (rotated ovals), RotRect, Outline4P..8P, FreePoly*, P and any other %AM macro are rendered geometrically: each flash is replaced by filled G36/G37 outlines — the same construct KiCad zone fills use, which CircuitCAM 3 imports fine. Rounded/rotated pads keep their exact shape (arcs approximated within 10 µm).
  • Drill tool renumbering: tool numbers are made unique across the PTH and NPTH files, fixing CircuitCAM's "last loaded file overwrites the tool diameter" behaviour.
  • Slot extraction: oval/slot holes (both G85 and routed G00/M15..M16 style) are removed from the drill files and drawn into a separate -SLOTS.gbr (line width = slot width) ready to be assigned to a milling layer for internal non-round cutouts.
  • Coordinate format (%FSLAX..) and units (%MOMM/%MOIN) are read from each file — nothing is hardcoded.
  • Clear per-file warnings for anything that cannot be represented in the old format.
  • Windows GUI (pure Win32, no dependencies) + command line mode.

Output

For base name CCAM3_MyBoard:

File Content
CCAM3_MyBoard.whl Unified aperture wheel for all layers
CCAM3_MyBoard-F_Cu.gbr, -B_Cu.gbr, -Edge_Cuts.gbr, … One converted Gerber per input layer (inch 2.3, leading zeros suppressed, RS-274D style)
CCAM3_MyBoard-PTH.drl, -NPTH.drl Excellon drills, tools renumbered, slots removed
CCAM3_MyBoard-SLOTS.gbr Slot/oval holes as thick lines, for contour milling

In CircuitCAM, import every .gbr with the same .whl aperture list (coordinates: inch, 2.3, absolute, leading zeros suppressed — as declared in the wheel header) and the .drl files as Excellon.

Usage

GUI

Run kicam.exe:

  1. Add Files... — multi-select the Gerber layers and drill files. Drills are auto-detected (they start with M48) and tagged [drill].
  2. The save directory and the base name (CCAM3_<project>) auto-fill; change them if you like.
  3. Convert — a summary lists the files written and any warnings.

Command line

kicam.exe <output_dir> <base_name> <file1> [file2 ...]
kicam.exe <input.gbr> <output.whl> <output.gbr>   (legacy single file)

Exit code 0 on success, 1 on failure; the report is printed to the console.

KiCad plot settings

Plot your Gerbers normally from KiCad (Protel filename extensions optional — files are sniffed, not judged by extension). No need to tick "Disable aperture macros": macros are fully supported. For drills, both the default decimal format and the 3.3/2.4 zero-suppressed formats work, and both oval-hole modes (route command or G85) are handled.

Format details

  • .whl: aperture sizes in 1/100 mm. The header (Format Unit: Inch, m.n Code: 2.3, …) describes the coordinates of the companion .gbr files, matching the reference wheels LPKF shipped with CircuitCAM.
  • .gbr: inch units, 2.3 format, leading zeros suppressed. Arcs (G02/G03/G75) and regions (G36/G37) are preserved; I/J arc centre offsets are converted along with X/Y.
  • .drl: passed through untouched except for tool renumbering and slot removal.

Known limitations

Reported as warnings during conversion:

  • %LPC (clear polarity), %SR step & repeat, moiré/thermal macro primitives and clear (exposure 0) macro primitives are not representable in the old format and are skipped.
  • Aperture holes are ignored (pads are solid) — irrelevant for isolation milling, the drill files carry the holes.
  • Trailing-zero-suppressed or incremental-coordinate Gerbers are rejected (KiCad never produces them).

Building

With MSYS2 MinGW (ucrt64):

windres resource.rc -O coff -o resource.o
g++ main.cpp GerberConverter.cpp resource.o -o kicam.exe \
    -std=c++11 -O2 -mwindows -static -lcomdlg32 -lshell32 -lole32 -lgdi32

Or with CMake:

cmake -S . -B build
cmake --build build --config Release

C++11, no external dependencies. Tip: build from a short path — windres can fail on very long or special-character paths (e.g. cloud-synced folders).

Examples

examples/ contains a real KiCad 9 bottom-copper layer (EXAMPLE.gbr) and the converted reference output (CCAM3_EXAMPLE.whl / CCAM3_EXAMPLE.gbr), verified against a working CircuitCAM 3 / ProtoMat C60 setup. They double as a regression test:

kicam.exe examples/EXAMPLE.gbr out.whl out.gbr

should produce files byte-identical to the reference pair.

Ideas / possible improvements

  • Drag & drop files onto the window
  • Remember the last used directory between sessions

License

MIT

About

KiCad to CircuitCAM 3 converter for LPKF ProtoMat PCB milling - unified aperture wheel, macro aperture support, drill tool renumbering, slot extraction

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages