Home Forums Nazca Subtraction of two layers Reply To: Subtraction of two layers


Dear Andreas,

Nazca does not do boolean operations on cells or layers (yet). However boolean operations are possible on polygons. So something as shown below might do the trick for you.

import nazca as nd

def invert_text(cell, layer1, layer2):
    lay1 = []
    lay2 = []
    layer1 = nd.get_layer(layer1)
    layer2 = nd.get_layer(layer2)
    for pgon in cell.polygons:
        node, Poly = pgon
        x0, y0, _ = node.xya()
        if Poly.layer == layer1:
            lay1.append([[x + x0, y + y0] for x, y in Poly.points])
        elif Poly.layer == layer2:
            lay2.append([[x + x0, y + y0] for x, y in Poly.points])
    with nd.Cell("newtxt") as newtxt:
        inverse = nd.clipper.diff_polygons(lay2, lay1)
        for pol in inverse:
            nd.Polygon(points=pol, layer=layer2).put()
    return newtxt

txt = nd.text(
    "Nazca-design", layer=1, box_layer=2, box_buf=20, align="cc"
inv = invert_text(txt, 1, 2)