2020-11-20 08:10:53 +00:00
|
|
|
#!/usr/bin/env python
|
2017-01-31 17:39:30 +00:00
|
|
|
import os.path
|
2012-05-01 15:13:36 +00:00
|
|
|
from pcbnew import *
|
|
|
|
|
|
|
|
size_025_160mm = wxSizeMM(0.25,1.6)
|
|
|
|
size_150_200mm = wxSizeMM(1.50,2.0)
|
|
|
|
pads = 40
|
|
|
|
|
|
|
|
# create a blank board
|
|
|
|
pcb = BOARD()
|
|
|
|
|
|
|
|
# create a new module, it's parent is our previously created pcb
|
2020-11-13 23:10:45 +00:00
|
|
|
module = FOOTPRINT(pcb)
|
2012-05-01 15:13:36 +00:00
|
|
|
module.SetReference("FPC"+str(pads)) # give it a reference name
|
2013-04-18 21:23:11 +00:00
|
|
|
module.Reference().SetPos0(wxPointMM(-1,-1))
|
2012-05-01 15:13:36 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
def smdRectPad(module,size,pos,name):
|
2020-11-14 01:06:05 +00:00
|
|
|
pad = PAD(module)
|
2012-05-01 15:13:36 +00:00
|
|
|
pad.SetSize(size)
|
2017-01-31 17:39:30 +00:00
|
|
|
pad.SetShape(PAD_SHAPE_RECT)
|
|
|
|
pad.SetAttribute(PAD_ATTRIB_SMD)
|
|
|
|
pad.SetLayerSet(pad.SMDMask())
|
2012-05-01 15:13:36 +00:00
|
|
|
pad.SetPos0(pos)
|
2017-08-11 09:22:13 +00:00
|
|
|
pad.SetName(name)
|
2012-05-01 15:13:36 +00:00
|
|
|
return pad
|
|
|
|
|
|
|
|
for n in range (0,pads):
|
|
|
|
pad = smdRectPad(module,size_025_160mm,wxPointMM(0.5*n,0),str(n+1))
|
|
|
|
module.Add(pad)
|
2014-02-13 17:27:48 +00:00
|
|
|
|
2012-05-01 15:13:36 +00:00
|
|
|
|
|
|
|
pad_s0 = smdRectPad(module,size_150_200mm,wxPointMM(-1.6,1.3),"0")
|
2014-02-13 17:27:48 +00:00
|
|
|
pad_s1 = smdRectPad(module,size_150_200mm,wxPointMM((pads-1)*0.5+1.6,1.3),"0")
|
2012-05-01 15:13:36 +00:00
|
|
|
module.Add(pad_s0)
|
|
|
|
module.Add(pad_s1)
|
|
|
|
|
2020-11-20 08:10:53 +00:00
|
|
|
e = FP_SHAPE(module)
|
2012-05-01 15:13:36 +00:00
|
|
|
e.SetStart0(wxPointMM(-1,0))
|
|
|
|
e.SetEnd0(wxPointMM(0,0))
|
|
|
|
e.SetWidth(FromMM(0.2))
|
2017-01-31 17:39:30 +00:00
|
|
|
e.SetLayer(F_SilkS)
|
2012-05-01 15:13:36 +00:00
|
|
|
e.SetShape(S_SEGMENT)
|
|
|
|
module.Add(e)
|
|
|
|
|
2017-01-31 17:39:30 +00:00
|
|
|
# save the footprint to disk
|
2018-08-01 14:31:50 +00:00
|
|
|
fpid = LIB_ID("", "FPC"+str(pads)) #the curr lin nickname (empty) and the name in library
|
2014-02-13 17:27:48 +00:00
|
|
|
module.SetFPID( fpid )
|
|
|
|
|
2017-01-31 17:39:30 +00:00
|
|
|
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:
|
2023-12-27 00:25:41 +00:00
|
|
|
dst_plugin.CreateLibrary(lib_name)
|
2017-01-31 17:39:30 +00:00
|
|
|
|
|
|
|
dst_plugin.FootprintSave(lib_name,module)
|