← Back to team overview

kicad-developers team mailing list archive

Use of std::vector<wxPoint> in Python

 

Hi,

I am trying to get fp_poly working in the footprint wizards. It seems
that I should be using pcbnew.DRAWSEGMENT.SetPolyPoints(), which takes a
std::vector<wxPoint> as an argument. I tried to feed it a Python list
of wxPoints, but it couldn't handle that:

 File "/home/john/src/kicad/pcbnew/scripting/tests/../plugins/FootprintWizardDrawingAids.py", line 367, in FilledPolygon
   outline.SetPolyPoints(xpts)
 File "/home/john/local/kicad/usr/lib/python2.7/dist-packages/pcbnew.py", line 5773, in SetPolyPoints
   return _pcbnew.DRAWSEGMENT_SetPolyPoints(self, *args)
TypeError: in method 'DRAWSEGMENT_SetPolyPoints', argument 2 of type 'std::vector< wxPoint,std::allocator< wxPoint > > const &'

I have never used SWIG before, but I tried to cargo-cult-hack something
into pcbnew/scripting/board.i like this:

 %template (wxPoint_Vector) std::vector<wxPoint>;

But this produced the following error when run:

 File "/home/john/src/kicad/pcbnew/scripting/tests/test_board.py", line 23, in <module>
   import pcbnew
 File "/home/john/local/kicad/usr/lib/python2.7/dist-packages/pcbnew.py", line 12041, in <module>
   class wxPoint_Vector(_object):
 File "/home/john/local/kicad/usr/lib/python2.7/dist-packages/pcbnew.py", line 12206, in wxPoint_Vector
   __swig_destroy__ = _pcbnew.delete_wxPoint_Vector
AttributeError: 'module' object has no attribute 'delete_wxPoint_Vector'

Does anyone know how a vector of wxPoints (or any class, more generally)
can be worked into the SWIG interface for use via Python?

Thanks,

John