Here is a quick example. I’ve got symbols in the schematic I use for things like PCB logos (these have no pins).
I can attach these to different footprints to select where the data goes. In this case the footprints are trivial, they have no graphic items, I’m just using the value. I cheated with the “text on copper” footprint, I had to edit that in a text editor, KiCad deprecates putting text on copper.
The PCB initially looks like this after netlist import:
The designators are hidden and don’t appear on PCB, just shown here for reference. Running the script
>>> execfile “test.py”
Setting module M3 Value to 2017-08-08
and the script
import sys
from datetime import datetime
import pcbnew
def testfunc():
my_board = pcbnew.GetBoard()
for module in my_board.GetModules():
fpid = module.GetFPID()
if fpid.GetFootprintName() == "text_auto_date":
new_text = "{:%Y-%m-%d}".format(datetime.now())
print ("Setting module %s Value to %s " % ( module.GetReference(), new_text ) )
module.Value().SetText(new_text)
testfunc()
I can’t see how to get to the sch file from the board object, is there another way?
board.GetFileName() should do it…


