summaryrefslogtreecommitdiff
path: root/pcbnew/scripting/examples/createPcb.py
diff options
context:
space:
mode:
authorsaurabhb172020-02-26 16:00:53 +0530
committerGitHub2020-02-26 16:00:53 +0530
commit886d9cb772e81d2e5262284bc3082664f084337f (patch)
tree6acee185a4dc19113fcbf0f9a3d6941085dedaf7 /pcbnew/scripting/examples/createPcb.py
parent0db48f6533517ecebfd9f0693f89deca28408b76 (diff)
parentaa35045840b78d3f48212db45da59a2e5c69b223 (diff)
downloadKiCad-eSim-886d9cb772e81d2e5262284bc3082664f084337f.tar.gz
KiCad-eSim-886d9cb772e81d2e5262284bc3082664f084337f.tar.bz2
KiCad-eSim-886d9cb772e81d2e5262284bc3082664f084337f.zip
Merge pull request #1 from saurabhb17/develop
Added main functions
Diffstat (limited to 'pcbnew/scripting/examples/createPcb.py')
-rwxr-xr-xpcbnew/scripting/examples/createPcb.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/pcbnew/scripting/examples/createPcb.py b/pcbnew/scripting/examples/createPcb.py
new file mode 100755
index 0000000..21c3803
--- /dev/null
+++ b/pcbnew/scripting/examples/createPcb.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python2.7
+from pcbnew import *
+
+size_0_6mm = wxSizeMM(0.6,0.6)
+size_1_0mm = wxSizeMM(1.0,1.0)
+
+# create a blank board
+pcb = BOARD()
+
+pcb.m_NetClasses.GetDefault().SetClearance(FromMM(0.1))
+
+# create a new module, it's parent is our previously created pcb
+module = MODULE(pcb)
+module.SetReference("M1") # give it a reference name
+module.Reference().SetPos0(wxPointMM(-10,-10))
+pcb.Add(module) # add it to our pcb
+m_pos = wxPointMM(50,50)
+module.SetPosition(m_pos)
+
+# create a pad array and add it to the module
+n = 1
+for y in range (0,10):
+ for x in range (0,10):
+ pad = D_PAD(module)
+ pad.SetDrillSize(size_0_6mm)
+ pad.SetSize(size_1_0mm)
+ pt = wxPointMM(1.27*x,1.27*y)
+ pad.SetPos0(pt);
+ #pad.SetPosition(pt)
+ pad.SetPadName(str(n))
+ module.Add(pad)
+ n+=1
+
+
+# save the PCB to disk
+pcb.Save("my2.kicad_pcb")
+pcb.Save("my2.brd")
+
+pcb = LoadBoard("my2.kicad_pcb")
+
+print map( lambda x: x.GetReference() , list(pcb.GetModules()))
+
+for m in pcb.GetModules():
+ for p in m.Pads():
+ print p.GetPadName(), p.GetPosition(), p.GetOffset()
+
+
+# pcb.GetDesignSettings()