← Back to team overview

kicad-developers team mailing list archive

Re: more pythonic scripting API for pcbnew

 

On 1/7/2015 8:33 AM, Tomasz Wlostowski wrote:
> On 07.01.2015 11:36, PTT wrote:
>> Dear all,
>> First of all thanks for all the good work, I recently switched to KiCAD
>> because of the added scripting support which I needed for scripted button
>> placement on a pcb.
>>
> 
> Hi Piers,
> 
> Very nice work, thanks! IMHO C++ APIs SWIGgged directly to python are
> rather big and inelegant and such a wrapper makes writing scripts much
> easier!
> 
> Are you intending to continue working on your wrapper? I vote for
> including it in future Kicad releases along with some examples. Miguel,
> Wayne - would you agree?

I think it's a good idea for developers who don't want to wade into all
of the swigged objects.  If Piers (or someone else) intends to maintain
it then we can add it as part of the python scripting installation.  If
not, then we can add it to the pcbnew/scripting/examples folder for user
convenience.

If I do add it the formatting issues will have to be addressed.  Tabs
are forbidden in all KiCad source code so you have to convert them to 4
spaces.  The trailing white space will also have to be cleaned up.
Although not strictly enforce, it is preferred that line lengths be
limited to 100 characters.  I also see some formatting inconsistencies
in functions with multiple arguments.  Some times there is a space after
the comma and sometimes there isn't so that should be addressed as well.

Thanks,

Wayne

> 
> Cheers,
> Tom
> 
> 
> 
>> To make it easier to get my work done I made some convenience functions and
>> classes wrapping the swig api to have a cleaner interface.
>>
>> Please have a look and see if it is useful to somehow incorporate it in the
>> main branch.
>>
>> pcbnew_easy.py
>> https://gist.github.com/pierstitus/7be2d9923da502c88ff1
>>
>> There is a simple usage example, to run put the file on your path, (or add
>> the path with sys.path.append("...path_to_file..."))
>> open the pcbnew console and enter
>>>>> import pcbnew_easy
>>>>> pcbnew_easy.test()
>> (the screen is only updating on moving)
>>
>> Piers
>>
>>
>>
>> _______________________________________________
>> 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
> 



Follow ups

References