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
485ec24f
Commit
485ec24f
authored
Apr 06, 2012
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method for MODULE in python that takes care of memory handling
parent
b54acf60
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
5 deletions
+62
-5
createPcb.py
pcbnew/scripting/examples/createPcb.py
+1
-5
module.i
pcbnew/scripting/module.i
+60
-0
pcbnew.i
pcbnew/scripting/pcbnew.i
+1
-0
No files found.
pcbnew/scripting/examples/createPcb.py
View file @
485ec24f
#!/usr/bin/env python
#!/usr/bin/env python
from
pcbnew
import
*
from
pcbnew
import
*
import
pcbnew
pcb
=
BOARD
()
pcb
=
BOARD
()
module
=
MODULE
(
pcb
)
module
=
MODULE
(
pcb
)
module
.
SetReference
(
"M1"
)
module
.
SetReference
(
"M1"
)
pad
=
D_PAD
(
module
)
pad
=
D_PAD
(
module
)
module
.
m_Pads
.
PushBack
(
pad
)
module
.
Add
(
pad
)
pad
.
thisown
=
0
pcb
.
Add
(
module
)
pcb
.
Add
(
module
)
pcb
.
Save
(
"/tmp/my2.brd"
)
pcb
.
Save
(
"/tmp/my2.brd"
)
print
map
(
lambda
x
:
x
.
GetReference
()
,
list
(
pcb
.
GetModules
()))
print
map
(
lambda
x
:
x
.
GetReference
()
,
list
(
pcb
.
GetModules
()))
print
"Saved?"
print
"Saved?"
pcbnew/scripting/module.i
0 → 100644
View file @
485ec24f
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file module.i
* @brief Specific BOARD extensions and templates
*/
%extend MODULE
{
%pythoncode
{
def GetPads(self): return self.m_Pads
def GetDrawings(self): return self.m_Drawings
#def SaveToLibrary(self,filename):
# return SaveModuleToLibrary(filename,self)
#
# add function, clears the thisown to avoid python from deleting
# the object in the garbage collector
#
def Add(self,item):
itemC = item.Cast()
if type(itemC) is D_PAD:
item.thisown=0
self.m_Pads.PushBack(itemC)
elif type(itemC) in [ TEXTE_PCB, DIMENSION, TEXTE_MODULE, DRAWSEGMENT]:
item.thisown = 0
self.m_Drawings.PushBack(item)
}
}
pcbnew/scripting/pcbnew.i
View file @
485ec24f
...
@@ -104,4 +104,5 @@
...
@@ -104,4 +104,5 @@
%include "board.i"
%include "board.i"
%include "module.i"
%include "units.i"
%include "units.i"
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