Is there Python script to import a PCB and interactively place it?

I would like to import/append a PCB into an existing empty board one at a time. How can I use python to interactively place the imported PCB? Is it possible to write a script that can increment/decrement the X and Y co-ordinates (1 Thou at a time until I press a stop button for instance) of the board so that it can be moved into an empty space on the page. I want to use a script so that I can speed up panellising several PCB’s into one board file.
Does anyone have an example script I can start with ? Thanks.

Hello
Yes, it exists.
You can see here

And here, the source for python script

Jean-Pierre

Hi,
Thanks. I don’t need to involve any schematics at all. I just need to move ALL the layers (copper AND drill etc) by the same offset. Here is a script for a layout cloner. I need to identify the part of the code that sets the X and Y co-ordinates of the imported board. I probably need a small dialog as well that allows me to stop any X and Y increments.

Can anyone identify which parts of the code above determines where the imported PCB ends up? Thanks.

David.

Here is another snippet

import sys, os

Add the home directory to sys.path

sys.path.append(“/home/mmccoo/kicad/kicad/install/lib/python2.7/dist-packages”)

import pcbnew

def append_board(main_board, other_board_file, offset):

offset = pcbnew.wxPoint(pcbnew.Millimeter2iu(offset[0]), pcbnew.Millimeter2iu(offset[1]))

other_board = pcbnew.LoadBoard(other_board_file)

for mod in list(other_board.GetModules()):
main_board.Add(mod)
mod.Move(offset)

for net in list(other_board.GetNetsByName().values()):
main_board.Add(net)

for track in list(other_board.GetTracks()):
main_board.Add(track)
track.Move(offset)

for zone in list(other_board.Zones()):
main_board.Add(zone)
zone.Move(offset)

pcbnew.Refresh()

#main_board = pcbnew.GetBoard()
print(“loading main”)
main_board = pcbnew.LoadBoard(“/home/mmccoo/empty.kicad_pcb”)
print(“loading other”)

other_board = “/bubba/electronicsDS/kicad/leddriver2/leddriver2.kicad_pcb”

print(“appending”)
append_board(main_board, other_board, (0,0))
print(“appending”)
append_board(main_board, other_board, (0,50))
print(“appending”)
append_board(main_board, other_board, (0,150))

print(“saving”)
pcbnew.SaveBoard(“/home/mmccoo/collage.kicad_pcb”, main_board)

print(“done”)

From

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