Prepare a board with pcbnew

Is there an already done example how to prepare a board layout with the python?
I mean setup the board dimensions, dump the text and the ritual sketches just to begin…

Thank You


Hi @pietrodcs,

Do you mean Help: Getting started in Kicad: Workflow:

Maybe start with something like:"Kicad"+python+scripting+example+tutorial

Can you further clarify what you want?
Your question can be interpreted in widely varying ways, and it looks like you actually have different questions mixed together.

What do you mean with:

and how do you want to combine that with Python?

My imagination is empty when trying to interpret:

I assume there is also a language barrier problem here.
If so, then maybe it helps if you first write it in your native language, then use an online translator, and then revise that text.

Asking good questions is an art in itself.
Erik Stephen Raymond has written quite ans essay about this topic, which is worth reading and thinking about.

Hello everyone,
I will try my best.
The beginning of every PCB has some standard actions to define the work.
The dimensions of the board is at first.
It is enough to place the line knowing the effective dimensions.
Then most probably 4 holes at a standard distance from the vertices.
Then some text in the form of logo …
During the drawing the eye can be fooled and one of the holes can be a little offset and the simmetry is lost.
A script taking the dimension of the board , the diameter of the holes and the distance from the vertices can place everything in the right place. The board is perfectly centered and sure the sides othogonal.
I am looking something like,

Thank all of You


KiCad has a grid and measuring tools. So it is possible to ensure that features are in the right positions using the GUI, no need to resort to running scripts.

There is no use in trying to script such a thing.
PCB’s are made in lots of different shapes and locations of mounting holes, and quite often also not in regular patterns.

Therefore the alternative is to use a drawing program, and just draw what you want. For fairly simple PCB outlines and mounting hole patterns, the built in drawing capabilities of Pcbnew are quite adequate. For more complex PCB outlines a better solution is to use an external mechanical CAD program to design the outline and mounting hole pattern and then export it in .dxf format and import it in Pcbnew.

In KiCad there are a few simple tricks to make simple patterns quick and effectively. The simplest method is to just use a coarse grid. I normally set the grid to whole millimeters when drawing the PCB outline and placing the mounting holes. With such a coarse grid, locations are either perfect, or so crooked that it’s easy to see.

Another method is to make some notes first with coordinates, and then you can press e for edit over any footprint or graphical line and enter those numbers directly into the text entry boxes.

In theory it could be done by manipulating footprints and line segments with a Python script in KiCad, but if you do it that way, you still have to get the right numbers for the coordinates from somewhere and enter them into the Python script. It just would not save any time.

If anyone wants to contribute I will listen to incoming suggestions.
Thank All of You


When you edit a geometry object (click on it then "E"dit), you have the accurate coordinates of the beginning and the end of the segment you clicked on, In addition, you can move “exactly”. So I don’t see where the problem is when placing edges or mounting holes or something else. On top of that you can import as .dxf any shape designed in a mechanical CAD software, especially from Freecad that has family links with kicad.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.