Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
f114e800
Commit
f114e800
authored
May 01, 2012
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for footprint library operations
parent
f3503723
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
0 deletions
+104
-0
createFPC40.py
pcbnew/scripting/examples/createFPC40.py
+59
-0
listPcbLibrary.py
pcbnew/scripting/examples/listPcbLibrary.py
+9
-0
module.i
pcbnew/scripting/module.i
+36
-0
No files found.
pcbnew/scripting/examples/createFPC40.py
0 → 100755
View file @
f114e800
#!/usr/bin/env python2.7
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
()
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
module
.
m_Reference
.
SetPos0
(
wxPointMM
(
-
1
,
-
1
))
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
):
pad
=
D_PAD
(
module
)
pad
.
SetSize
(
size
)
pad
.
SetShape
(
PAD_RECT
)
pad
.
SetAttribute
(
PAD_SMD
)
pad
.
SetLayerMask
(
PAD_SMD_DEFAULT_LAYERS
)
pad
.
SetPos0
(
pos
)
pad
.
SetPadName
(
name
)
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
)
pad_s0
=
smdRectPad
(
module
,
size_150_200mm
,
wxPointMM
(
-
1.6
,
1.3
),
"0"
)
pad_s1
=
smdRectPad
(
module
,
size_150_200mm
,
wxPointMM
((
pads
-
1
)
*
0.5
+
1.6
,
1.3
),
"0"
)
module
.
Add
(
pad_s0
)
module
.
Add
(
pad_s1
)
e
=
EDGE_MODULE
(
module
)
e
.
SetStart0
(
wxPointMM
(
-
1
,
0
))
e
.
SetEnd0
(
wxPointMM
(
0
,
0
))
e
.
SetWidth
(
FromMM
(
0.2
))
e
.
SetLayer
(
EDGE_LAYER
)
e
.
SetShape
(
S_SEGMENT
)
module
.
Add
(
e
)
# save the PCB to disk
module
.
SetLibRef
(
"FPC"
+
str
(
pads
))
try
:
FootprintLibCreate
(
"fpc.mod"
)
except
:
pass
# we try to create, but may be it exists already
FootprintSave
(
"fpc40.mod"
,
module
)
pcbnew/scripting/examples/listPcbLibrary.py
0 → 100644
View file @
f114e800
#!/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
.
GetPads
():
print
"
\t
"
,
p
.
GetPadName
(),
p
.
GetPosition
(),
p
.
GetOffset
()
\ No newline at end of file
pcbnew/scripting/module.i
View file @
f114e800
...
...
@@ -59,3 +59,39 @@
}
%pythoncode
{
def GetPluginForPath(lpath):
return IO_MGR.PluginFind(IO_MGR.LEGACY)
def FootprintEnumerate(lpath):
plug = GetPluginForPath(lpath)
return plug.FootprintEnumerate(lpath)
def FootprintLoad(lpath,name):
plug = GetPluginForPath(lpath)
return plug.FootprintLoad(lpath,name)
def FootprintSave(lpath,module):
plug = GetPluginForPath(lpath)
return plug.FootprintSave(lpath,module)
def FootprintDelete(lpath,name):
plug = GetPluginForPath(lpath)
plug.FootprintDelete(lpath,name)
def FootprintLibCreate(lpath):
plug = GetPluginForPath(lpath)
plug.FootprintLibCreate(lpath)
def FootprintLibDelete(lpath):
plug = GetPluginForPath(lpath)
plug.FootprintLibDelete(lpath)
def FootprintIsWritable(lpath):
plug = GetPluginForPath(lpath)
plug.FootprintLibIsWritable(lpath)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment