Delete shapes

edited October 2017 in Python scripting
I try to cut layers using the Points (p1,p2) of a ruler.
So far I've go the result but I'm not able to delete the original shapes on the current layer.
The script runs through without any error but still the original shape is in.

Any idea is highly appreciated ...


myLayer = layout.layer(1, 0)
l0 = pya.Region()
l0.insert(pya.Box(p1.x, p1.y ,p2.x+1000, p2.y+1000))

l1 = layout.begin_shapes(topcell,myLayer)
l2 = pya.Region(l1)
result = l2-l0

####### Here I try to delete the original shapes
shapes = topcell.shapes(myLayer)
shapes.erase
#topcell.shapes(lay).erase
########


# insert modified shapes
topcell.shapes(myLayer).insert(result)

Thanks in advance,
Andy

Comments

  • edited October 2017

    Hi Andy,

    the solution is to clear the layer entirely:

    layout.clear_layer(myLayer)
    

    Matthias

  • edited October 2017
    Thanks a lot Matthias,
    It works as planned.


    With the programmable interface KLayout is a real outstanding tool !

    Cheers,
    Andy
Sign In or Register to comment.