It looks like you're new here. If you want to get involved, click one of these buttons!
Dear Mattias
I am saving the value of begin_shapes_rec into the following variable "dies_ol":
dies_ol = pya.Region(cell.begin_shapes_rec( layer_ol ))
After this I add new shapes in "layer_ol" into the cell.
This changes the value contained in dies_ol variable.
Is this expected or is this a new behaviour ?
Because in the past I think Klayout would keep the original variable value.
Maybe I should not use begin_shapes_rec this way. in this case I wish you could letme know what should I use insteadt.
I am attaching the input gds and the script to reproduce this.
Please let me know
Thank you in advance
Best regards
Giovanni
Comments
Hi Giovanni,
yes, that is intended.
Actually, when you create a Region with a recursive shape iterator, it becomes a special kind of Region called an "original layer region". It is not a replica of the layer, but represents the actual layer inside the source layout. This feature is preventing unnecessary and expensive copies. Also, such a region remains hierarchical, hence saving memory.
In order to "freeze" a Region, you can use "flatten". But beware, this will do what it says and may explode your hierarchy.
For example, this code reproduces your problem:
As you experienced, it will print the same shapes, although the second shape was added after the region 1 was created:
With "flatten", the copy is frozen:
and it prints:
Matthias
Thank you Matthias for the detailed explanation.
I wil change my code and make shure that I add .flatten() when I need to freeze the content of the region.
Thank you again
Best regards
Giovanni