2012-04-08 14:25:49 +00:00
|
|
|
#!/usr/bin/env python2.7
|
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
|
|
|
|
2012-04-09 06:19:57 +00:00
|
|
|
pcb.m_NetClasses.GetDefault().SetClearance(FromMM(0.1))
|
|
|
|
|
2012-04-08 14:25:49 +00:00
|
|
|
# create a new module, it's parent is our previously created pcb
|
2012-04-06 19:48:00 +00:00
|
|
|
module = MODULE(pcb)
|
2012-04-08 14:25:49 +00:00
|
|
|
module.SetReference("M1") # give it a reference name
|
2013-04-18 21:23:11 +00:00
|
|
|
module.Reference().SetPos0(wxPointMM(-10,-10))
|
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):
|
|
|
|
pad = D_PAD(module)
|
|
|
|
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);
|
2012-04-09 06:19:57 +00:00
|
|
|
#pad.SetPosition(pt)
|
2012-04-08 14:25:49 +00:00
|
|
|
pad.SetPadName(str(n))
|
|
|
|
module.Add(pad)
|
|
|
|
n+=1
|
|
|
|
|
2012-04-06 19:48:00 +00:00
|
|
|
|
2012-04-08 14:25:49 +00:00
|
|
|
# save the PCB to disk
|
2012-04-14 21:18:27 +00:00
|
|
|
pcb.Save("/tmp/my2.kicad_brd")
|
2012-04-22 11:14:58 +00:00
|
|
|
pcb.Save("/tmp/my2.brd")
|
2012-04-08 14:25:49 +00:00
|
|
|
|
2012-04-22 11:14:58 +00:00
|
|
|
pcb = LoadBoard("/tmp/my2.brd")
|
2012-04-08 14:25:49 +00:00
|
|
|
|
2012-04-06 19:48:00 +00:00
|
|
|
print map( lambda x: x.GetReference() , list(pcb.GetModules()))
|
|
|
|
|
2012-04-08 14:25:49 +00:00
|
|
|
for m in pcb.GetModules():
|
2013-04-18 21:23:11 +00:00
|
|
|
for p in m.Pads():
|
|
|
|
print p.GetPadName(), 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()
|