Kicad Component Layout
Introduction
A KiCad plugin for quick programmatic layout of components on your PCB.
I've done a number of board designs that involve laying out a lot of footprints in precise locations that are more easily described in code than via the KiCad UI. I wrote previously about programmatic component layout in KiCad, but since then I've refined the process a fair bit. The code run in Kicad is reduced to a single plugin script, which you can find here: https://github.com/mcbridejc/kicad_component_layout.
The basic premise is that you, the designer, write a script (could be python, or whatever you prefer) to generate a layout.yaml, and in KiCad you execute the plugin to sync the instructions in the layout.yaml file to your PCB design. This means that you can iterate and update your design without having to constantly reload the kicad plugin, and also if you work on multiple projects that use auto-generated placements, you don't need to manage separate plugins for each project (I think project associated plugins would be a great feature for Kicad, but alas it is not available at the moment).
Example layout.yaml
The layout file can change the positions, rotation, flip status (top/bottom), and the footprint for a component based on designators. I think a quick example of a layout file should give the idea:
origin: [x0, y0] # Offset applied to all component locations
components:
R1:
location: [x, y] # mm
rotation: [r] # degrees
flipped: false
footprint:
path: path/to/library.pretty
name: SomeFootprint
J1:
...
Github
There are more instructions on the github project. If you find it useful, or have suggestions for how to expand it, feel free to open an issue or email with suggestions. I'm pretty open to expanding it to cover more use cases if anyone else finds it useful. I've found that this simple plugin handles all of the programmatic use cases I've needed, and it avoids the need for project specific code to be installed as a KiCad plugin.