Use Python script to place Via?


I am new to kicad, and I want to create a simple mechanical board with holes… I was thinking about using "Via" to make all my holes.

I have the list of holes with position and diameter I want in my board, and instead of adding all corresponding Via manually I was wondering if there is a way to use a Python script to place all Via for me.

I was looking for a simple kicad python script example on internet with only one via, then I would be able to modify I for all the via I want to add… But I didn’t find such example …

Thank you in advance.

Best regards.

import pcbnew

b = pcbnew.BOARD()
v = pcbnew.VIA(b)
v.SetPosition(pcbnew.wxPoint(30000000, 20000000))
pcbnew.SaveBoard("board.kicad_pcb", b)

You can see what else you can do with the via class here:

A board with just holes is very easily created starting with just one via (if you insist) and the ‘Create array…’ command in Pcbnew. Just like that.

Place a via, right click on it, set array parameters, done.

Repeat if required for different via distributions.

Thank you !
I will try it.

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