Thanks for the explantation about BOARD_ACTIONS, it looks clean.

I've been implementing a couple of nice things over DLIST, that now can
be iterated with standard python loops, also the BOARD_ITEM/EDA_ITEM
polymorphic class is handled in a very natural way, with the extended
.Cast() method
(implemented in BOARD_ITEM from .i, no cpp modification for that).

from pcbnew import *
pcb = LoadBoard(filename)

ToUnits=ToMils
FromUnits=FromMils

print "LISTING VIAS+TRACKS:"

for item in pcb.GetTracks():  #internally calls .Cast() at each
iteration of the tracks list

        if type(item) is SEGVIA:

                pos = item.GetPosition()
                drill = item.GetDrillValue()
                width = item.GetWidth()
                print " * Via:   %s - %f/%f 
"%(ToUnits(pos),ToUnits(drill),ToUnits(width))
                
        elif type(item) is TRACK:
                
                start = item.GetStart()
                end = item.GetEnd()
                width = item.GetWidth()
                
                print " * Track: %s to %s, width %f" %
(ToUnits(start),ToUnits(end),ToUnits(width))
                
        else:
                print "Unknown type     %s" % type(item)

Full example here:
http://bazaar.launchpad.net/~miguelangel-r/kicad/scripting/view/head:/pcbnew/scripting/examples/listPcb.py

Here we can start to work with the magic of dynamic typing in
scripting languages

http://bazaar.launchpad.net/~miguelangel-r/kicad/scripting/view/head:/scripting/dlist.i
http://bazaar.launchpad.net/~miguelangel-r/kicad/scripting/view/head:/pcbnew/scripting/board_item.i


Greetings :-)


--

Miguel Angel Ajo Pelayo
http://www.nbee.es
+34 636 52 25 69
skype: ajoajoajo

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to