← Back to team overview

kicad-developers team mailing list archive

Re: Pcbnew Python Interface breakage?

 

Hi Maurice,

This is due to the recent commit that enables iterators for DLISTs. We
have forgotten that such change impacts the Python interface.

I propose to keep the old interface, otherwise we will face many reports
when a script works correctly with the stable release, but not with
nightlies.

Would you check if the attached patch fixes the problem? If so, I will
push it.

Regards,
Orson

On 06/26/2017 10:23 AM, easyw wrote:
> Hi,
> I can confirm the same error on windows 10.
> 
> I get also an other kind of error in my annular plugin that worked till now
> 
> "for pad in module.Pads():
> TypeError 'SwigPyObject' object is not iterable"
> 
> BR
> Maurice
> 
> On 06/25/2017 5:46 PM, Simon Küppers wrote:
>> Hi,
>> I just updated KiCad on Linux Mint using the Launchpad PPA to test the
>> new connection algorithm. However, a SWIG error starts to pop up in my
>> python plugins.
>> Right now I can produce the error, when calling GetDrawings on the board
>> object (which worked a few days ago). It looks like the SWIG wrappers
>> are desynchronized from the C++-code. Is that (at all) possible?
>>
>> This is the Traceback I get:
>>
>> ----
>> Traceback (most recent call last):
>>
>>   File "/home/sk/.kicad_plugins/action_viafence/viafence_action.py",
>> line 160, in Run
>>     boardItem = self.boardObj.GetDrawings().GetFirst()
>>
>>   File "/usr/lib/python2.7/dist-packages/pcbnew.py", line 18508, in
>> GetDrawings
>>     def GetDrawings(self):            return self.m_Drawings
>>
>>   File "/usr/lib/python2.7/dist-packages/pcbnew.py", line 17803, in
>> <lambda>
>>     __getattr__ = lambda self, name: _swig_getattr(self, BOARD, name)
>>
>>   File "/usr/lib/python2.7/dist-packages/pcbnew.py", line 74, in
>> _swig_getattr
>>     return _swig_getattr_nondynamic(self, class_type, name, 0)
>>
>>   File "/usr/lib/python2.7/dist-packages/pcbnew.py", line 69, in
>> _swig_getattr_nondynamic
>>     return object.__getattr__(self, name)
>>
>> AttributeError: type object 'object' has no attribute '__getattr__'
>>
>> Best Regards
>> Simon
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp
>>
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp

From 6dce744039e6991438e615d3cd5f84d9cb07b437 Mon Sep 17 00:00:00 2001
From: Maciej Suminski <maciej.suminski@xxxxxxx>
Date: Mon, 26 Jun 2017 14:22:32 +0200
Subject: [PATCH] Fix the BOARD & MODULE classes SWIG interface

---
 pcbnew/swig/board.i  | 3 +--
 pcbnew/swig/module.i | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/pcbnew/swig/board.i b/pcbnew/swig/board.i
index 62cbaed73..05d04d516 100644
--- a/pcbnew/swig/board.i
+++ b/pcbnew/swig/board.i
@@ -115,9 +115,8 @@ HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints)
     %{
 
     def GetModules(self):             return self.m_Modules
-    def GetDrawings(self):            return self.m_Drawings
+    def GetDrawings(self):            return self.DrawingsList()
     def GetTracks(self):              return self.m_Track
-    def GetFullRatsnest(self):        return self.m_FullRatsnest
 
     def Save(self,filename):
         return SaveBoard(filename,self,IO_MGR.KICAD)
diff --git a/pcbnew/swig/module.i b/pcbnew/swig/module.i
index b27376654..14274dde0 100644
--- a/pcbnew/swig/module.i
+++ b/pcbnew/swig/module.i
@@ -48,6 +48,9 @@
     %pythoncode
     %{
 
+    def Pads(self):            return self.PadsList()
+    def GraphicalItems(self):  return self.GraphicalItemsList()
+
     #def SaveToLibrary(self,filename):
     #  return SaveModuleToLibrary(filename,self)
 
-- 
2.12.0

Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups

References