Dear all,
I would like to subtract two layers. In the following example, I am trying to create two layer with one box in each. Then I would like to put the subtraction of the two layers in a new layer. How should I proceed ? Here is the starting point of the code :
import pya
import math
# Create Layout
layout = pya.Layout()
# Create cell
TopCell = layout.create_cell("Cell1")
# Create layers
Layer0 = layout.layer(1, 0)
Layer1 = layout.layer(2, 0)
# Create boxes
box1 = pya.Box(-2400, -2400, 2400, 1500)
box2 = pya.Box(-10, -10, 210, 210)
TopCell.shapes(Layer0).insert(box1)
TopCell.shapes(Layer1).insert(box2)
layout.write('bla.gds')
How to subtract Layer0 and Layer1 and put them in a new layer ?
Thanks a lot.
Comments
Hello,
There is a simple way to do this using a DRC script:
the basic way using plain Python is via the pya.Region object. A Region object is basically a collection of polygons and offers boolean and many other operations:
Matthias
This answer has helped me greatly, thank you! The "region" class is quite hidden in the documentation.