← Back to team overview

kicad-developers team mailing list archive

Re: more pythonic scripting API for pcbnew

 

Hi folks,

Good work!

I dunno, LordBlick, it looks pretty Pythonic to me!

Also, I do not think

 dict(map(lambda lname: lname, layers_tuple.index(lname), layers_tuple))

is clearer than using a dictionary called layer_dict :)

Adam Wolf
Cofounder and Engineer
W&L


On Wed, Jan 7, 2015 at 12:25 PM, LordBlick <lordblick@xxxxxxxxx> wrote:

> In response to a message written on 07.01.2015, 11:36, from PTT:
>
>> 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
>>
> Very good work for adding it to pcbnew/scripting/examples/, but it will
> not let anything be loaded by default. Each developer has their own habits
> and not everything looks like a purely written code in my eyes. Much of
> coding is to tune up some project than writing down some script, which will
> be creating tracks or vias. Well, unless someone recode freerouter to
> python ...;)
>
> BTW. Some advice to make better world ;) :
> - via.SetLayerPair(layer_pair[0], layer_pair[1]) looks better as
> via.SetLayerPair(*layer_pair)
> - „def mm” is bad - there are two methods in pcbnew - FromMM and ToMM,
> both useful…
> - layer_dict is not comfortable way - as layers are defined as int, better
> and easier done it will put these string names by correct order in tuple.
> Any dict (if really needed) can be created dynamically from tuple by
> function:
>  dict(map(lambda lname: lname, layers_tuple.index(lname), layers_tuple))
> Alternative for tuple is getattr(pcbnew, lname):
> >>> getattr(pcbnew, 'F_Cu')
> 0
> >>> getattr(pcbnew, 'In1_Cu')
> 1
> I wish you many wins with python battles… ;)
> --
> Best Regards,
> LordBlick
>
>
> _______________________________________________
> 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