2018-08-04 15:11:45 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
2012-04-06 19:48:00 +00:00
|
|
|
from pcbnew import *
|
|
|
|
|
2012-04-08 14:59:12 +00:00
|
|
|
size_0_6mm = wxSizeMM(0.6,0.6)
|
2012-04-09 06:19:57 +00:00
|
|
|
size_1_0mm = wxSizeMM(1.0,1.0)
|
2012-04-08 14:25:49 +00:00
|
|
|
|
|
|
|
# create a blank board
|
2012-04-06 19:48:00 +00:00
|
|
|
pcb = BOARD()
|
2012-04-08 14:25:49 +00:00
|
|
|
|
2018-08-01 14:31:50 +00:00
|
|
|
pcb.GetNetClasses().GetDefault().SetClearance(FromMM(0.1))
|
2012-04-09 06:19:57 +00:00
|
|
|
|
2012-04-08 14:25:49 +00:00
|
|
|
# create a new module, it's parent is our previously created pcb
|
2020-11-13 23:10:45 +00:00
|
|
|
module = FOOTPRINT(pcb)
|
2012-04-08 14:25:49 +00:00
|
|
|
module.SetReference("M1") # give it a reference name
|
2018-08-01 14:31:50 +00:00
|
|
|
module.Reference().SetPos0(wxPointMM(6,-2))
|
|
|
|
module.Reference().SetDrawCoord()
|
2012-04-08 14:25:49 +00:00
|
|
|
pcb.Add(module) # add it to our pcb
|
2012-04-09 06:19:57 +00:00
|
|
|
m_pos = wxPointMM(50,50)
|
2012-04-08 14:25:49 +00:00
|
|
|
module.SetPosition(m_pos)
|
2012-04-06 19:48:00 +00:00
|
|
|
|
2012-04-09 06:19:57 +00:00
|
|
|
# create a pad array and add it to the module
|
2012-04-08 14:25:49 +00:00
|
|
|
n = 1
|
|
|
|
for y in range (0,10):
|
|
|
|
for x in range (0,10):
|
2020-11-14 01:06:05 +00:00
|
|
|
pad = PAD(module)
|
2012-04-08 14:25:49 +00:00
|
|
|
pad.SetDrillSize(size_0_6mm)
|
2012-04-09 06:19:57 +00:00
|
|
|
pad.SetSize(size_1_0mm)
|
|
|
|
pt = wxPointMM(1.27*x,1.27*y)
|
2012-04-08 14:25:49 +00:00
|
|
|
pad.SetPos0(pt);
|
2018-08-01 14:31:50 +00:00
|
|
|
pad.SetDrawCoord()
|
2017-08-11 09:22:13 +00:00
|
|
|
pad.SetName(str(n))
|
2012-04-08 14:25:49 +00:00
|
|
|
module.Add(pad)
|
|
|
|
n+=1
|
2014-02-13 17:27:48 +00:00
|
|
|
|
2012-04-06 19:48:00 +00:00
|
|
|
|
2012-04-08 14:25:49 +00:00
|
|
|
# save the PCB to disk
|
2014-02-13 17:27:48 +00:00
|
|
|
pcb.Save("my2.kicad_pcb")
|
2012-04-08 14:25:49 +00:00
|
|
|
|
2014-02-13 17:27:48 +00:00
|
|
|
pcb = LoadBoard("my2.kicad_pcb")
|
2012-04-08 14:25:49 +00:00
|
|
|
|
2020-11-13 23:03:36 +00:00
|
|
|
print(map( lambda x: x.GetReference() , list(pcb.GetFootprints())))
|
2012-04-06 19:48:00 +00:00
|
|
|
|
2020-11-13 23:03:36 +00:00
|
|
|
for m in pcb.GetFootprints():
|
2013-04-18 21:23:11 +00:00
|
|
|
for p in m.Pads():
|
2018-08-04 15:11:45 +00:00
|
|
|
print('pad ', p.GetName(), p.GetPosition(), p.GetOffset())
|
2012-04-08 14:25:49 +00:00
|
|
|
|
2012-04-09 06:19:57 +00:00
|
|
|
|
2012-04-14 21:18:27 +00:00
|
|
|
# pcb.GetDesignSettings()
|