← Back to team overview

kicad-developers team mailing list archive

Re: Python Plugin - Use of advanced LSET Constructor

 

In response to a message written on 03.03.2015, 01:08, from nats:
Thanks a lot for this information.
I managed to get it working, after some discussion on IRC I copied the
LSET code
inside the plugin.
It'll be removed when kicad python new api will be ready.
Here is the link for reference:
https://github.com/natsfr/kicad-components/blob/master/python_plugins/qfn_wizard.py
If you have any remark on the code don't hesitate.
Try out that code:
_from_LayerSet = lambda layerset: tuple(map(lambda n:pcbnew.BOARD_GetStandardLayerName(n), layerset.Seq()))
LSEQ() now is functional in python(methods clear(), append()), but it's not
possible to reassign modified LSQ to LSET
BTW. Consider restricting the use of names of layers for presentation to the
user. Other operations will be faster if we were operating on layers IDs, which
are ordinary integers.
Layers = tuple([B.BOARD_GetStandardLayerName(idl) for idl in range(B.LAYER_ID_COUNT)])
lsCuLayers = tuple(filter(lambda layerName: layerName.endswith('.Cu'), Layers))
layerName2ID = lambda txtLayer: Layers.index(txtLayer) if txtLayer in Layers else -1
layerID2Name = lambda layerID: Layers[layerID] if type(layerID) is int and(layerID in range(len(Layers))) else ''

--
Best Regards,
LordBlick


References