kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #15621
Re: Python scripting - Zone/Area manager
Le 06/11/2014 12:02, LordBlick a écrit :
> In response to a message written on 06.11.2014 10:58, from jp charras:
>> ZONE_CONTAINER::Outline() returns m_Poly, which is a pointer to a
>> CPolyLine, which contains polygons (zone outlines: main outline and
>> holes)
>> -- Jean-Pierre CHARRAS
>
> Thanks for info, but I have no idea, what I can make with
> "<Swig Object of type 'CPolyLine *' at 0x7f08ee3d1630>".
> Provided python methods of this are:
>>>> zone=pcb.GetArea(0)
>>>> ol=zone.Outline()
>>>> for strAttr in dir(ol):
> ... _attr = getattr(ol, strAttr)
> ... if callable(_attr):
> ... print("ol.%s()" % strAttr)
CPolyLine now is mapped in python since revision 5253
Attached a file which read and print zones and outlines corner lists
from a board.
>
> I've read this:
> http://www.swig.org/Doc1.3/Python.html#Python_nn55
> But I'm not so familiar with C++
I'm myself not so familiar with Python.
--
Jean-Pierre CHARRAS
#!/usr/bin/env python
import sys
from pcbnew import *
filename=sys.argv[1]
pcb = LoadBoard(filename)
ToUnits = ToMM
FromUnits = FromMM
#ToUnits=ToMils
#FromUnits=FromMils
print "List zones:"
for idx in range(0, pcb.GetAreaCount()):
item = pcb.GetArea(idx)
outline = item.Outline()
print "zone %d, outline %d corners %d" \
% ( idx, outline.GetContoursCount(), outline.GetCornersCount() )
polynum = 1;
startcnt = True
for idc in range(0, outline.GetCornersCount()):
if( startcnt ):
print " ** contour %d" % polynum
startcnt = False
print " corner %d @ %f %f mm" \
%( idc, ToUnits( outline.GetX(idc) ), ToUnits( outline.GetY(idc) ) )
if( outline.IsEndContour( idc ) ):
polynum += 1
startcnt = True
Follow ups
References