Home Forums Nazca Subtracting two rectangle polygons Reply To: Subtracting two rectangle polygons


Dear Theflyingpengin,

When you put() an object, the return type is None, which explains the error message. You can easily check this by printing e.g. the type of base:


The polygon operations of the clipper module require lists of polygons, where a polygon is a list of (x,y) values. So the first and second argument of diff_polygons() should be something like [[(1,2),(3,4),(5,1)]].

A small working example similar to your example (but with different polygon placement) would be:

import nazca as nd
import nazca.geometries as geom

base = geom.parallelogram(length=7333.87, height=3803.27, angle=90, position=1, shift=(0, 0))
# base is a polygon and [base] is a list of polygons (with only one polygon).
straights = geom.parallelogram(length=6180.09, height=758, angle=90, position=1, shift=(0, 0))
polygons = nd.clipper.diff_polygons([base], [straights], accuracy=0.001)

for pol in polygons:  # There is only one polygon in the result in this case.
    nd.Polygon(pol, layer=4).put()


Hope that helps you to go on.

Lastly a word of warning: subtracting or combining polygons may result in a “hole”. This is not handled by Nazca, because GDS cannot handle such polygons.