Hi all,
I’m developing a script to panelize KiCad boards automatically, e.g. for a v-scored panel of a few small identical boards. The idea is that it will be fed an existing board design and, given an array size, make an appropriate panel of the given board, adding siderails, v-scoring information and fiducials automatically.
Right now, I can easily create an appropriate array of tracks, zones, text, and everything except modules by using the Duplicate()
function. Here’s an example codeblock from my script that create an array of tracks:
# array of tracks
tracks = sourceBoard.GetTracks()
newTracks = []
for sourceTrack in tracks: # Iterate through each track to be copied
for x in range(0,arrayXnum): # Iterate through x direction
for y in range(0, arrayYnum): # Iterate through y direction
if((x!=0)or(y!=0)): # Don't duplicate source object to location
newTrack = sourceTrack.Duplicate()
newTrack.Move(wxPoint(x*boardWidth, y*boardWidth)) # Move to correct location
newTracks.append(newTrack) # Add to temporary list of tracks
for track in newTracks: # add new tracks to board
tracks.Append(track)
print("tracks copied.")
The above works perfectly for tracks, and similarly for zones and text.
When I try to do something similar with modules, the Duplicate()
function doesn’t work as it requires two arguments for modules:
>>> module.Duplicate()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Duplicate() missing 2 required positional arguments: 'aItem' and 'aIncrementPadNumbers'
I’ve tried passing it the item I want to duplicate and tried both True
and False
for aIncrementPadNumbers
, but I’m having no luck.
I also looked into simply loading another footprint via pcbnew.PCB_IO().LoadFootprint()
, but that requires a footprint library path to be specified, and I couldn’t figure out any way of getting that information from an existing footprint.
As you can probably tell, I’m pretty new to Python in general, and this is also my first time trying to script KiCad. Any help or pointers here would be greatly appreciated!