Skip to content

Exporting KiCad footprints

The KiCad footprint exporter writes the project's copper as one KiCad footprint (.kicad_mod), so an antenna or filter designed in RayRF can be placed on a board like any other part. It is available under File, Export and as a CLI command.

Exporting from the editor

Select File, Export, KiCad footprint (.kicad_mod). The dialog asks for the footprint name and the KiCad copper layer for each conductor layer. By default the top conductor goes on F.Cu, the bottom one on B.Cu, and inner ones on In1.Cu onward in stack order. A project with one conductor layer goes on F.Cu. Choose Leave out for a layer the footprint should not carry, such as a ground plane the board already has. Click Export and choose the file.

Cancel stops the export without writing a file. Nothing is written until the whole footprint is built. The Console lists the pads, nets, layers and ports, and anything that was approximated.

What the footprint holds

RayRF geometryIn the footprint
Copper on a mapped layerOne SMD pad with a custom shape per connected copper island, on the island's KiCad layer
ViaA through-hole pad with the via's drill and outer diameter
Plated hole or slotA through-hole pad the size of its drill. The copper around it is the island's own pad
Unplated hole or slotA non-plated pad, round or oval
CutoutA closed outline on Edge.Cuts
PortA text label (P1, P2) on F.Fab at the port. Ports are not copper
A shape on a dielectric layerLeft out, and named in the report

The copper is what the simulation realizes on each layer: every positive shape joined, less every negative shape, with via pads added after the cut and the unplated holes and cutouts taken out. Pads carry copper only, with no solder mask opening and no paste. Add those in KiCad if the board needs them.

KiCad pad polygons can't have holes, so copper with holes in it (a ground plane with a clearance, say) is written as several polygons inside one pad. They are cut from vertex to vertex, so together they cover exactly the same copper.

Pad numbers are nets

Pads with the same number in a KiCad footprint are one net. Copper islands joined by a via or a plated hole get the same number, including through a layer you left out. Separate islands get separate numbers. The nets the ports touch are numbered first, in port order, then the rest left to right and top to bottom. The same project always exports the same numbers and the same file.

For each port the report names the pads its terminals touch, for example P1: signal pad 1, reference pad 2. The signal terminal is the port's positive terminal and the reference is its negative one. A terminal that touches no copper is named as such, and so is one that touches copper on a layer the footprint leaves out.

Stackup and placement

A footprint carries no stackup. It behaves as simulated only on the stackup it was designed on, so the file's description and the report list that stackup: each layer's name, and each dielectric's thickness and permittivity.

Coordinates are in millimeters with Y pointing down, the KiCad convention, and the footprint origin is the project origin. Placing the footprint at a board coordinate puts the project origin there, so the copper lands where it was drawn relative to it.

Curves and precision

Round edges (circles, arcs, via pads, round holes and curved script shapes) are flattened at a relative chord tolerance of 1e-4, the same rule the DXF export uses, and the report says so. Imported bitmap copper is written as its exact pixel rectangles. Imported board artwork keeps its own stated tolerance.

KiCad stores footprints on a 1 nm grid. Coordinates are fitted to it, and the report states the largest move. A feature narrow enough that the fit would move its outline by more than a thousandth of its width is refused, naming the narrowest one. KiCad also stores coordinates as 32-bit counts of nanometers, so a footprint has to lie within 2147.48 mm of its origin.

The file is in the KiCad 7 footprint format (version 20221018), which KiCad 7, 8, 9 and 10 open. It carries no UUIDs, since KiCad assigns them when it loads the file.

Exporting from the CLI

rayrf project export-kicad-footprint --project FILE --out FILE [--replace]
    [--json] [--layer LAYER=KICAD]... [--name NAME]

--layer Top=F.Cu puts conductor Top on F.Cu, and --layer Ground= leaves Ground out. Conductors you don't name keep the default. --name sets the footprint name, which is otherwise the output file name. The .kicad_mod suffix is added when --out doesn't have it, and an existing file refuses unless --replace is set.

Without --json the outcome and one line per port go to stdout and each warning to stderr. --json writes this schema to stdout:

{
  "schema": "rayrf-kicad-footprint-export-report/v1",
  "project_file": "/work/patch.rfsim",
  "output_path": "/work/patch.kicad_mod",
  "footprint_name": "patch",
  "kicad_format_version": 20221018,
  "layer_map": {"Top": "F.Cu", "Bottom": "B.Cu"},
  "pad_count": 2,
  "net_count": 2,
  "ports": [
    {"port_number": 1, "summary": "P1: signal pad 1, reference pad 2.",
     "terminals": [
       {"role": "signal", "layer": "Top", "pads": [1], "state": "pads"},
       {"role": "reference", "layer": "Bottom", "pads": [2], "state": "pads"}]}
  ],
  "report": {"exported": [], "approximated": [], "omitted": [], "warnings": []}
}

Refused exports

These refuse the whole export with the reason, and nothing is written:

  • A blind or buried via. A KiCad footprint pad drills through the whole board, so it can't stand for a via that stops partway.
  • A hole or cutout that runs through only part of the stack.
  • A plated cutout, since Edge.Cuts carries no plating.
  • No conductor layer mapped to a KiCad layer, or two conductors on the same KiCad layer.
  • A feature too fine for the 1 nm grid, or copper beyond KiCad's coordinate range.
  • A footprint name KiCad can't hold, such as one with / or : in it.

An SMD pad on an inner KiCad layer is written as mapped, and KiCad's DRC reports it as a questionable padstack (a warning). KiCad puts a through-hole pad that reaches F.Cu and B.Cu on every copper layer of the board, so a via or plated hole also gets pads on inner layers you left out.