I cannot seem to assign a net to a pad that is loaded from a footprint through python scripting.
I suspect it might be caused by netlist in module and netlist in board.
The code:
indent preformatted text by 4 spaces
#initialize new pad
footprint_lib = 'rlib.pretty';
mod = pcb_io.FootprintLoad(footprint_lib, "dummy pad");
#set position of via
position1 = pcbnew.wxPoint(x1,y1);
mod.SetPosition(position1);
newpad = mod.GetPad(position1);
if(netname != "nonet"):
#get list of nets
nets = pcb_board.GetNetsByName();
#get net that matches netname
net = nets.find(netname).value()[1];
#set net of via
newpad.SetNetCode(net.GetNet());
print("net to assign: " + str(net.GetNet()));
print("net of newpad:" + str(newpad.GetNetCode()));
#add new pad to board
pcb_board.Add(mod);
For output, I get net to assign as 3 and net of newpad as 0.
Alternatively, how can a pad be made through python scripting? I haven’t been able to figure that out.