Update a really outdated python script example, and remove a too old example.
This commit is contained in:
parent
75b08e49cf
commit
66ed8f00ca
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
import os.path
|
||||||
from pcbnew import *
|
from pcbnew import *
|
||||||
|
|
||||||
size_025_160mm = wxSizeMM(0.25,1.6)
|
size_025_160mm = wxSizeMM(0.25,1.6)
|
||||||
|
@ -8,8 +9,6 @@ pads = 40
|
||||||
# create a blank board
|
# create a blank board
|
||||||
pcb = BOARD()
|
pcb = BOARD()
|
||||||
|
|
||||||
pcb.m_NetClasses.GetDefault().SetClearance(FromMM(0.1))
|
|
||||||
|
|
||||||
# create a new module, it's parent is our previously created pcb
|
# create a new module, it's parent is our previously created pcb
|
||||||
module = MODULE(pcb)
|
module = MODULE(pcb)
|
||||||
module.SetReference("FPC"+str(pads)) # give it a reference name
|
module.SetReference("FPC"+str(pads)) # give it a reference name
|
||||||
|
@ -24,9 +23,9 @@ module.SetPosition(m_pos)
|
||||||
def smdRectPad(module,size,pos,name):
|
def smdRectPad(module,size,pos,name):
|
||||||
pad = D_PAD(module)
|
pad = D_PAD(module)
|
||||||
pad.SetSize(size)
|
pad.SetSize(size)
|
||||||
pad.SetShape(PAD_RECT)
|
pad.SetShape(PAD_SHAPE_RECT)
|
||||||
pad.SetAttribute(PAD_SMD)
|
pad.SetAttribute(PAD_ATTRIB_SMD)
|
||||||
pad.SetLayerMask(PAD_SMD_DEFAULT_LAYERS)
|
pad.SetLayerSet(pad.SMDMask())
|
||||||
pad.SetPos0(pos)
|
pad.SetPos0(pos)
|
||||||
pad.SetPadName(name)
|
pad.SetPadName(name)
|
||||||
return pad
|
return pad
|
||||||
|
@ -45,16 +44,19 @@ e = EDGE_MODULE(module)
|
||||||
e.SetStart0(wxPointMM(-1,0))
|
e.SetStart0(wxPointMM(-1,0))
|
||||||
e.SetEnd0(wxPointMM(0,0))
|
e.SetEnd0(wxPointMM(0,0))
|
||||||
e.SetWidth(FromMM(0.2))
|
e.SetWidth(FromMM(0.2))
|
||||||
e.SetLayer(EDGE_LAYER)
|
e.SetLayer(F_SilkS)
|
||||||
e.SetShape(S_SEGMENT)
|
e.SetShape(S_SEGMENT)
|
||||||
module.Add(e)
|
module.Add(e)
|
||||||
|
|
||||||
# save the PCB to disk
|
# save the footprint to disk
|
||||||
fpid = LIB_ID("FPC"+str(pads)) #the name in library
|
fpid = LIB_ID("FPC"+str(pads)) #the name in library
|
||||||
module.SetFPID( fpid )
|
module.SetFPID( fpid )
|
||||||
|
|
||||||
try:
|
lib_name = "fpc40.pretty" #lib_path is actually a path, not a file
|
||||||
FootprintLibCreate("fpc40.mod")
|
dst_type = IO_MGR.GuessPluginTypeFromLibPath( lib_name );
|
||||||
except:
|
dst_plugin = IO_MGR.PluginFind( dst_type )
|
||||||
pass # we try to create, but may be it exists already
|
|
||||||
FootprintSave("fpc40.mod",module)
|
if os.path.exists(lib_name) == False:
|
||||||
|
dst_plugin.FootprintLibCreate(lib_name)
|
||||||
|
|
||||||
|
dst_plugin.FootprintSave(lib_name,module)
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
from pcbnew import *
|
|
||||||
|
|
||||||
lst = FootprintEnumerate("/usr/share/kicad/modules/sockets.mod")
|
|
||||||
|
|
||||||
for name in lst:
|
|
||||||
m = FootprintLoad("/usr/share/kicad/modules/sockets.mod",name)
|
|
||||||
print name,"->",m.GetLibRef(), m.GetReference()
|
|
||||||
|
|
||||||
for p in m.Pads():
|
|
||||||
print "\t",p.GetPadName(),p.GetPosition(),p.GetPos0(), p.GetOffset()
|
|
||||||
|
|
Loading…
Reference in New Issue