← Back to team overview

kicad-developers team mailing list archive

Re: Pcbnew Python Interface breakage?

 

I changed this so that we could provide partial footprint library
loading for plugins that support one file per item.  This is an
unfortunate side effect of using exceptions.  In order to provide the
partial list of parsed footprint files, I had to pass a reference to the
array.  Nothing gets returned when an exception is thrown.

Don't be surprised when there are Python API changes in the development
branch.  It is going to happen from time to time.  The API shouldn't
change for a stable release series.

On 6/27/2017 2:56 AM, Maciej Sumiński wrote:
> Hi Kaspar,
> 
> This change is not related to the connectivity branch merge.
> 
> PLUGIN::FootprintEnumerate() signature has changed [1] and now instead
> of returning wxArrayString, it takes one as a reference and fills it out.
> 
> Regards,
> Orson
> 
> 1.
> https://github.com/KiCad/kicad-source-mirror/commit/3cec63e9b92d2a1ca2d62c2c344a6274c06b5744#diff-0c21b12f202b8b1c75014639447406bbL200
> 
> On 06/26/2017 07:27 PM, Kaspar Emanuel wrote:
>> Since people seem to be able to give the updates from off the top of their
>> heads, what do I need to update this footprint loading script
>> <https://github.com/monostable/kicad_footprints/blob/ef8c2c0c3e91b8a45f2b864c6a165dd6215a8398/load_all.py>?
>> I am getting:
>>
>> Traceback (most recent call last):
>>   File "load_all.py", line 22, in <module>
>>     list_of_footprints = src_plugin.FootprintEnumerate(libpath)
>>   File "/usr/lib/python2.7/dist-packages/pcbnew.py", line 4386, in
>> FootprintEnumerate
>>     return _pcbnew.PLUGIN_FootprintEnumerate(self, *args)
>> NotImplementedError: Wrong number or type of arguments for overloaded
>> function 'PLUGIN_FootprintEnumerate'.
>>   Possible C/C++ prototypes are:
>>     PLUGIN::FootprintEnumerate(wxArrayString &,wxString const
>> &,PROPERTIES const *)
>>
>> PLUGIN::FootprintEnumerate(wxArrayString &,wxString const &)
>>
>> ​
>>
>> On 26 June 2017 at 17:30, Maciej Sumiński <maciej.suminski@xxxxxxx> wrote:
>>
>>> Great, thank you both for testing! I have just pushed the patch.
>>>
>>> Maurice, you are right about the comment. It was already there, but
>>> should have been removed.
>>>
>>> Regards,
>>> Orson
>>>
>>> On 06/26/2017 05:16 PM, easyw wrote:
>>>> Hi,
>>>>
>>>> I solved with a trick
>>>>             try:
>>>>                 board_drawings=board.GetDrawings()
>>>>             except:
>>>>                 board_drawings=board.DrawingsList()
>>>>
>>>>             for drw in board_drawings:
>>>>
>>>> for one plugin, and with a similar trick for the other;
>>>> but your solution is cleaner.
>>>>
>>>> is the
>>>> diff --git a/pcbnew/swig/module.i b/pcbnew/swig/module.i
>>>> correct?
>>>>
>>>> I see there is a block comment before @line 45
>>>> /*
>>>> %extend MODULE
>>>> ...
>>>>
>>>> Applying the patch I cannot make any plugins running
>>>> but if I de-comment that block it works...
>>>>
>>>>
>>>> Thx
>>>> Maurice
>>>>
>>>>
>>>> On 06/26/2017 2:24 PM, Maciej Sumiński wrote:
>>>>> 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
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>
>>>
>>
> 
> 
> 
> 
> _______________________________________________
> 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
> 


References