KiCad pre place script

Hi there.

I wrote a python script to place the footprint like the Eechema’s layout.

KiCad pre place script (Youtube)

KiCad pre place script(github source)

Try it!

5 Likes

Looks good.
Does it support hierarchical design?

Interesting. I was thinking something like that could be integrated in the kicad.
I had an idea of something similar but more complex: the alg will place the components minimizing the connection distances and where the components will be used.
eg: On your example you show that the power jack position in the schematic was based to place it on the PCB board. But I was thinking something that will place the components closer how they are used, like if you have a bypass capacitor, it will look on the net and try to place closer the pin it will be used. (sometimes in the schematic you dont place it on the same position as it should be logical in the board).

3 Likes

Thanks for reply.

I published this script one year ago.
I am considering supporting hierarchical maps, but they are still in the planning stage.

Wait a bit. :slight_smile:

1 Like

About bypass capacitor, I think so too.

Personally, I place the bypass capacitor close to the necessary components, but I also know how to put it in another block.
I was considering the possibility of placing them on a hierarchical sheet, so I did not support hierarchical sheets.
Therefore, this is for some analog circuits.

I hope that various placement support tools will be released and used properly depending on conditions.

If a bypass capacitor is placed in another block, it will be necessary to give Eeschema components an attribute that links the relationship with the main component.

For the moment, I have not considered that much.

Eeschema may have attributes of neighboring components and circuit blocks as defaults in components. Rather, I want it.

I think you don’t need it… but. as I said… it would need some kind of “artificial intelligence” :slight_smile:
because… usually (some) people place the capacitors bank in one place. They label the NETs that they are filtering. So you may just need to spread that capacitors close to a PIN that also has the same NET. Maybe in this case it is harder because you will need to know where the GND is… (may not be labeled as GND but other thing…)
but… thats just a guess anyway…

1 Like

I think you would need more information than the schematic provides.
Does the user want the cap near the connector or near the ic (only to mention one example)
This could be signaled by using the distance in the schematic. This means the user can reliably control where it should be placed. (As long as it is documented one can make assumptions.)

I see. I also use other board CAD, but I feel that the concept of net labels and proximity placement is diverse.

If component placement by AI becomes possible, board design becomes much easier.

Please note that this is a script that places the footprint as in the circuit diagram, not a tool to optimize the placement.
In an actual PCB, naturally, footprints are placed on both sides of the front and back sides.

In other words, it is based on the premise that humans optimize placement.
Someday, AI may be able to examine the placement in detail.

This day will come sooner than many of us might like.
(In ic design, a lot of stuff can already be auto placed and auto routed.)
But i’m also sure that more stuff will be integrated into one package. In the future a pcb might have a lot less components on it.

1 Like

There are maybe things that can be set to help AI, true. But at this moment (and thinking that KiCad devs will not change or add new parameters) there are already some things that could help the automatic placement. One good example is the Pcbnew allows you to “lock” the position of the modules. So, for example, you can place first the connectors and mechanical parts (that need to match your design), fix it and some algorithm can place based on that pre-fixed positions the other modules.

Edit: even if that AI is not very good for what you want, you can start placing (by locking positions) more important modules and let the others to be automatically placed.

1 Like

Hey there!
I was using Hiro’s script and i needed hierarchical sheet support. So i took the opportunity and adopted that script to support them. It is still under testing though…
@Hiro: write me that we can exchange the sources…

1 Like

Hey there !
I’m new for scripting and new on Kicad. Actually, I need to place my components automatically on the PCB.
The script made by @Hiro looks good but i’m using hierarchical sheet. It seems that you (@ebno79) succeed in it.
Is that possible to get your script ?

Wow!
Sorry I did not notice.
Are you testing the source now?
If you do not mind, please send me a pull request.

I just caught on.
Even with correspondence other than hierarchy sheets, I welcome pull requests.

@ebno79 Would be interested in your changes as well since I am using multiple sheets now. Would you like to share your script and @Hiro can pull in changes the old fashioned way.

Sorry, I lost track because I was not notified that you all replied. As I am not into github can @Hiro tell me how to send you an pull request?
Thanks