← Back to team overview

kicad-developers team mailing list archive

Re: Patch to fix pcbnew example scripts and SWIG interface

 

Thanks for the feedback, I have prepared a new patch that removes the
simple pass-through python-only accessor methods as discussed. I applied
the changes to the scripting example files, and tested the createPcb.py and
listPcbLibrary.py. There was a problem with the listPcb.py script, in
trying to call GetText() and GetPosition() on a TEXTE_PCB object. I am not
sure how to fix that one immediately offhand, but I will look into it more
in the next days.

Thanks,
Matthew Beckler
Wayne and Layne, LLC


On Mon, Apr 8, 2013 at 7:22 PM, Cirilo Bernardo
<cirilo_bernardo@xxxxxxxxx>wrote:

> Using 'XXX()' instead of 'GetXXX()' makes more sense if you're replacing a
> pair of Get/Set routines, but this is really only a consistency issue with
> Python.
>
> - Cirilo
>
> PS. Sorry for the top post; goddamned Yahoo doesn't allow a user to create
> messages in a sensible fashion anymore.  Stinking google's screwing things
> up too.  Is there anyone out there who still gives you good old plain text
> and quoting/indentation?
>
>
>
> >________________________________
> > From: Miguel Angel Ajo <miguelangel@xxxxxxx>
> >To: Matthew Beckler <matthew.beckler@xxxxxxxxx>
> >Cc: KiCad Developers <kicad-developers@xxxxxxxxxxxxxxxxxxx>
> >Sent: Tuesday, April 9, 2013 6:27 AM
> >Subject: Re: [Kicad-developers] Patch to fix pcbnew example scripts and
> SWIG interface
> >
> >
> >Hey, thanks a lot Matthew,
> >
> >
> >    This happened because of the ongoing class interface cleanup Wayne is
> working on,
> >    I will apply the patch as soon as I check it,
> >
> >
> >    I put the GetValue / GetPads, etc in place, to be ready for those
> changes,
> >but then It seems that later I forgot while writing the examples..
> >
> >
> >     I think that it could make sense to change the GetXXX() to XXX()
> directly, just
> >removing the wrappers, and keeping everything else the same way.
> >
> >
> >     What do you think?
> >
> >
> >Greetings,
> >Mike.
> >
> >
> >
> >
> >
> >Miguel Angel Ajo
> >http://www.nbee.es/
> >+34911407752
> >skype: ajoajoajo
> >
> >
> >On Monday, 8 de April de 2013 at 21:43, Matthew Beckler wrote:
> >Hello,
> >>
> >>
> >>I've been trying to explore the python scripting interface for pcbnew. I
> see that some changes have been made to the pcbnew/class_module.h file,
> such that GetReference() returns a wxString& and Reference() returns the
> TEXTE_MODULE& itself.
> >>
> >>
> >>To get the scripting examples to work again, I made a few small changes
> in pcbnew/scripting/module.i :
> >>
> >>
> >>=== modified file 'pcbnew/scripting/module.i'
> >>--- pcbnew/scripting/module.i2012-05-16 09:35:18 +0000
> >>+++ pcbnew/scripting/module.i2013-04-08 19:27:00 +0000
> >>@@ -33,10 +33,10 @@
> >>   %pythoncode
> >>   {
> >>
> >>-    def GetPads(self):      return self.m_Pads
> >>-    def GetDrawings(self):            return self.m_Drawings
> >>-    def GetReferenceObj(self):      return self.m_Reference
> >>-    def GetValueObj(self):      return self.m_Value
> >>+    def GetPads(self):                return self.Pads()
> >>+    def GetDrawings(self):            return self.GraphicalItems()
> >>+    def GetReferenceObj(self):        return self.Reference()
> >>+    def GetValueObj(self):            return self.Value()
> >>
> >>     #def SaveToLibrary(self,filename):
> >>     #  return SaveModuleToLibrary(filename,self)
> >>@@ -52,10 +52,10 @@
> >>
> >>     if type(itemC) is D_PAD:
> >>     item.thisown=0
> >>-    self.m_Pads.PushBack(itemC)
> >>+    self.GetPads().PushBack(itemC)
> >>     elif type(itemC) in [ TEXTE_PCB, DIMENSION, TEXTE_MODULE,
> DRAWSEGMENT,EDGE_MODULE]:
> >>     item.thisown = 0
> >>-    self.m_Drawings.PushBack(item)
> >>+    self.GetDrawings().PushBack(item)
> >>   }
> >>
> >> }
> >>
> >>
> >>I also made some changes to two of the example scripts in
> pcbnew/scripting/examples/ to work with these new functions instead of
> accessing e.g. m_Reference directly (as that member is now Private).
> >>
> >>
> >>Hopefully I have prepared the patch correctly and followed all coding
> standards. Please let me know if I need to fix the patch in any way.
> >>
> >>
> >>Thanks much,
> >>Matthew Beckler
> >>
> >>Wayne and Layne, LLC
> >>_______________________________________________
> >>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
> >>
> >>Attachments:
> >>- mbeckler_patch_pcbnew_scripting_module_createPcb_createFPC40.py
> >
> >
> >_______________________________________________
> >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
> >
> >
> >
>

Attachment: mbeckler_pcbnew_scripting_unencapsulate.patch
Description: Binary data


Follow ups

References