How do you create a polygon with holes in python?

I have been able to create a solid polygon on any layer using a DRAWSEGMENT and ds.SetShape(pcbnew.S_POLYGON) then calling ds.SetPolyPoints(wxpointlist).

This works very well. I then tried adding holes to the SHAPE_POLY_SET:

ds.GetPolyShape( ).AddHole( pcbnew.SHAPE_LINE_CHAIN( wxPointList) )

And I get the error “Wrong number or type of arguments”.

Anyone know how to create a DRAWSEGMENT S_POLYGON with holes in python?

SHAPE_LINE_CHAIN doesn’t have a constructor that takes wxPoint list. You can create it using default constructor and then Append() points.

1 Like

Awesome. I think that’s working for me. Creating DRAWSEGMENT S_POLYGONs from SVG (something’s wrong with the right side of this “PHI” symbol):

Edit: using this code (where geom[1:] is my list of wxPoints and ds is the previously-defined S_POLYGON)


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.