It looks like you're new here. If you want to get involved, click one of these buttons!
Hello,
I want to remove instances which do not overlap with a circular form using a Python script.
For sure, Klayout gives the possibility to check the overlap betwwen two boxes, but I don't see how to check the overlap between a box and a circular form.
box=....
if not box.overlaps(db.Box(inst.bbox())):
inst.delete()
Thank you.
Regards,
Comments
@ahmedo
This will find all boxes outside of a layer/circle
Run the script and you will see a circle with boxes inside,
click undo and you can see what has been removed
If I understand @ahmedo correctly he said not overlapping, so instead of
outside = r2 & r1
it should be
not_outside = r2.select_not_outside(r1)
and then
topcell.shapes(output).insert(not_outside)
r1 & r2
will cut parts of boxes that are outside of the circle.@sebastian
I may have misread .. but good point and thanks for highlighting this, we all learn
No worries ^^. I also think overlapping is not clearly defined in daily speech, so you may very well be correct. Regions were confusing when I started with KLayout, so I wanted to point out that there are fancy options in the regions included that might save a lot of time.
Thank you @tagger5896 and @sebastian for your valuable help.
I will make a test with your code. I see that the code looks for the name of the layout at the beginning, so I guess I need to run the script using the command line:
klayout -r <script.py> my.gds
Is it right ?
By the way I have implemented a solution that allows me to check the overlap:
Regards
For my question I think that I have undestood that @tagger5896 's code should be executed from macro menu
I'm used to creating scripts that I execute always in batch mode.
Regards
@ahmedo
You should have an open layout and run the code from the Macro IDE menu yes.
@tagger5896
Thank you so much for your help.
Regards
@sebastian
thanks for pointing this out ... floodgates open and the sea's part,
and yes this makes it easier
not_outside = r2.select_not_outside(r1)
@ahmedo @sebastian
New thread https://www.klayout.de/forum/discussion/1790/boolean-functions-based-on-regions-functions-to-add-box-circle-path-and-polygon#latest