How to best automatically place 100 SMD resistors in the PCB without manually moving?

OK, maybe someone has an advice for a simple project. Working with some HV stuff I had the idea to populate a PCB with many 1206 resistors and use it as HV load resistors.

How to best place them in the PCB without manually moving 100 resistors?


I tried it with Claude Sonnet 4.5 working on a PCB file with the resistors already there:

make python script to edit the positions of resistors r1 to r100
use r1 position as top left reference,
arrange all resistors in a grid 5 mm spacing
r1 r2 r3 r4 to the right
r1 r11 r21 etc to the bottom
y direction is increasing downwards
make 10x10 matrix

which surprisingly took a handful of iterations. My guess is that the 500k PCB file is too large for Claude to work on efficiently. Not sure though.
@devbisme from the variants you selected, do you think there’s a more efficient approach?

BTW 5 PCBAs (resistors soldered) are $13 or so with JLC.

Does it have to be scripting?

Is a standard Right Click → Align / Distribute → Distribute Horizontally or Vertically by Centre or Gap (whatever you prefer) not good / fast enough?

There is also the Array tool. Right mouse click > Select > Create from selection > Create Array.

@devbisme The question was not about how to best place 100 resistors. In the other post (where IMO this question belongs) you listed various git repos for LLM interfacing. My intention was to hear your opinion on what you would think an efficient LLM based approach could be, given a more defined problem vs. the original rather hazy “how do I do AI with KiCad” question.

The most efficient approach would be to ask the LLM to perform the task and be done with it.

But this approach often doesn’t work. Processing KiCad files is a heavy lift. There’s a lot of picky syntax where the LLM can inject errors, and there’s a lot of extraneous text that has nothing to do with a particular problem but it still gets inserted into the context window. Plus LLMs are not noted for their ability to perform arithmetic if that is needed (e.g., placing components, routing wires, etc.).

An approach that’s more likely to succeed has two phases:

  1. Ask the LLM what scripts/utilities could be used alone or in combination to solve a problem. For any of these that do not already exist, have it write them.
  2. Ask the LLM to apply the scripts/utilities to solve the problem.

(For the particular problem that started all this, maybe ask the LLM to develop a utility for moving components in a .kicad_pcb file and then have it use it to arrange the resistors into the pattern you want.)

Using the scripts keeps the LLM out of the nitty-gritty of handling the file details while allowing it to use its programming expertise. And LLMs have gotten gotten good at using tools and there are frameworks for this.

Also note that you can be involved in either or both phases: you may already know what scripts are needed and/or how to apply them to solve the problem. So you can steer the solution rather than throwing everything into the LLM and hoping for the best.

With regards to existing scripts/utilities, there are many (like kicad-skip) that the LLMs could use. Also, circuit-synth has a lot of machinery that could be employed even if you don’t use the entire package.

As you wrote directly editing the PCB files probably does not work well. Claude even struggled writing a pythons script to edit the coordinates, obviously it hat problems reverse-engineering the data structure.

Besides circuit-synth etc. I remember there was a not really well documented python API - maybe that might be better? On the other hand, if it is not well known the LLM will have trouble finding out how to use it.

As you wrote directly editing the PCB files probably does not work well. Claude even struggled writing a pythons script to edit the coordinates, obviously it hat problems reverse-engineering the data structure.

I had to use AI to write an s-expession library (simp_sexp) when I was modifying kipart because it wasn’t able to understand the structure of modern KiCad libraries. Some manual problem decomposition can be helpful.

On the other hand, if it is not well known the LLM will have trouble finding out how to use it.

There has been a push over the last year to include an llms.txt file inside websites that summarizes the content in a concise Markdown file so as to make it easier for AI to understand it. I expect this to become the norm as it becomes important for the AI to drive the tools instead of us.