createPcb.py 1.15 KB
Newer Older
1
#!/usr/bin/env python2.7
2 3
from pcbnew import *

4
size_0_6mm = wxSizeMM(0.6,0.6)
5
size_1_0mm = wxSizeMM(1.0,1.0)
6 7

# create a blank board
8
pcb = BOARD()
9

10 11
pcb.m_NetClasses.GetDefault().SetClearance(FromMM(0.1))

12
# create a new module, it's parent is our previously created pcb
13
module = MODULE(pcb)
14
module.SetReference("M1")   # give it a reference name
15
module.m_Reference.SetPos0(wxPointMM(-10,-10))
16
pcb.Add(module)             # add it to our pcb
17
m_pos = wxPointMM(50,50)
18
module.SetPosition(m_pos)
19

20
# create a pad array and add it to the module
21 22 23 24 25
n = 1
for y in range (0,10):
    for x in range (0,10):
        pad = D_PAD(module)
        pad.SetDrillSize(size_0_6mm)
26 27
        pad.SetSize(size_1_0mm)
        pt = wxPointMM(1.27*x,1.27*y)
28
        pad.SetPos0(pt);
29
        #pad.SetPosition(pt)
30 31 32 33
        pad.SetPadName(str(n))
        module.Add(pad)
        n+=1
        
34

35
# save the PCB to disk
Miguel Angel Ajo's avatar
Miguel Angel Ajo committed
36
pcb.Save("/tmp/my2.kicad_brd")
37
pcb.Save("/tmp/my2.brd")
38

39
pcb = LoadBoard("/tmp/my2.brd")
40

41 42
print map( lambda x: x.GetReference() , list(pcb.GetModules()))

43 44 45 46
for m in pcb.GetModules():
    for p in m.GetPads():
        print p.GetPadName(),p.GetPosition(), p.GetOffset()

47

Miguel Angel Ajo's avatar
Miguel Angel Ajo committed
48
# pcb.GetDesignSettings()