It looks like you're new here. If you want to get involved, click one of these buttons!
Hey folks,
I am trying to make a simple "multi clip" script that takes a list of boxes and clips a layout file similar to how this tool works:
edit->utilities->Clip Tool->multi clip
I found a few discussions that are close to showing how to do this:
https://www.klayout.de/forum/discussion/916/wrong-order-of-multi-clip
https://www.klayout.de/forum/discussion/167/density-for-a-layer
https://www.klayout.de/forum/discussion/comment/493#Comment_493
https://www.klayout.de/forum/discussion/comment/345#Comment_345
I think it would be something very simple like this, but the output.oas file is empty
import pya
layout_file = "C:/~/input.oas"
layout = pya.Layout.new()
layout.read(layout_file)
top_cell = layout.cell('my_top_cell_name')
bblist = [
# Left, Right, Bottom, Top
pya.Box.new(0, 1000, 0, 1000),
pya.Box.new(1001, 2000, 1001, 2000)
]
clip_layout = pya.Layout.new()
clip_layout.dbu=layout.dbu
for layer_id in layout.layer_indexes():
clip_layout.insert_layer_at(layer_id, layout.get_info(layer_id))
clip_cells = layout.multi_clip_into(top_cell.cell_index(), clip_layout, bblist)
clip_layout.write("C:/~/output.oas")
Thanks,
Scott
Comments
Hi Scott,
you gave me some headache before I found the problem
Here is the explanation: the box coordinates are actually left, bottom, right, top. So the list should be:
With your definition you clipped only single points. A clip at a single point gives as much as fits into a point which is nothing
Matthias
Thank you Matthias. Small problem... each bbox clip goes into a separate cell. Any way to make all clips go into one cell? Like how the multi clip utility arranges all the cells under a new top cell named CLIP
Thanks,
Scott
Also thank you a bunch for looking into this... that's quite a dumb mistake putting the bbox corners in the wrong order
Hi Scott,
that's easy. Just instantiate the new cells into a new top cell:
Regards,
Matthias
Thanks Matthias! I am slowly getting more comfortable with the Klayout scripting API. This is going to save a lot of time and effort for a bunch of poor lithography engineers