← Back to team overview

kicad-developers team mailing list archive

Re: more pythonic scripting API for pcbnew

 

In response to a message written on 16.01.2015, 18:10, from Piers Titus van der Torren:
About units: For me it was a big benefit to be able to just use any 2 element
tuple like object for coordinates and sizes, and direct numbers for other
values, and not having to use a conversion to internal units all the time. I do
a lot of my calculations with numpy, so it makes things a lot easier if numpy
arrays can be used directly.
To me it makes most sense to use mm as default unit for the python API, and
convert from inches to mm using a simple inch2mm function.
Why not use KiCAD internal units ? Any necessary geometric calculation can be implemented in compiled _pcbnew.so
Also we can look onto Cython…

Furthermore I put my script in a github repository, like Wayne suggested, I hope
this leads to more organized experimenting, please clone and improve. It can be
found at https://github.com/pierstitus/kicad-python

LordBlick, thanks for another improvement to the layer conversion, it is much
better to use the names that are used in the GUI ('F.Cu' instead of 'F_Cu').
As Jean-Pierre Charras wrote in thread nearly, board names for cooper layers may vary:
brd = pcbnew
pcb = brd.GetBoard()
>>> pcb.SetLayerName(0, 'Top')
True
>>> pcb.SetLayerName(31, 'Bottom')
True
>>> pcb.SetLayerName(32, 'BottomGlue')
False
>>>

It's committed to the github repo above.
Thank you for cooperate… :)

--
Best Regards,
LordBlick


Follow ups

References