Update a really outdated python script example, and remove a too old example.

This commit is contained in:
jean-pierre charras 2017-01-31 18:39:30 +01:00
parent 75b08e49cf
commit 66ed8f00ca
2 changed files with 14 additions and 24 deletions

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python2.7
import os.path
from pcbnew import *
size_025_160mm = wxSizeMM(0.25,1.6)
@ -8,8 +9,6 @@ pads = 40
# 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("FPC"+str(pads)) # give it a reference name
@ -24,9 +23,9 @@ module.SetPosition(m_pos)
def smdRectPad(module,size,pos,name):
pad = D_PAD(module)
pad.SetSize(size)
pad.SetShape(PAD_RECT)
pad.SetAttribute(PAD_SMD)
pad.SetLayerMask(PAD_SMD_DEFAULT_LAYERS)
pad.SetShape(PAD_SHAPE_RECT)
pad.SetAttribute(PAD_ATTRIB_SMD)
pad.SetLayerSet(pad.SMDMask())
pad.SetPos0(pos)
pad.SetPadName(name)
return pad
@ -45,16 +44,19 @@ e = EDGE_MODULE(module)
e.SetStart0(wxPointMM(-1,0))
e.SetEnd0(wxPointMM(0,0))
e.SetWidth(FromMM(0.2))
e.SetLayer(EDGE_LAYER)
e.SetLayer(F_SilkS)
e.SetShape(S_SEGMENT)
module.Add(e)
# save the PCB to disk
# save the footprint to disk
fpid = LIB_ID("FPC"+str(pads)) #the name in library
module.SetFPID( fpid )
try:
FootprintLibCreate("fpc40.mod")
except:
pass # we try to create, but may be it exists already
FootprintSave("fpc40.mod",module)
lib_name = "fpc40.pretty" #lib_path is actually a path, not a file
dst_type = IO_MGR.GuessPluginTypeFromLibPath( lib_name );
dst_plugin = IO_MGR.PluginFind( dst_type )
if os.path.exists(lib_name) == False:
dst_plugin.FootprintLibCreate(lib_name)
dst_plugin.FootprintSave(lib_name,module)

View File

@ -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()