Hello,
I need to find the (x,y) coordinates of certain shapes drawn in a certain layer. These (x,y) coordinates are all the positions of all the shapes inside the top cell; the shapes can be in subcells or arrays.
The work flow I currently use is as follows: with the top cell as the top view, I merge the specific layer. In this way, the data on the layer is also flattened. Next, I use the "Search and Replace" function to Find shapes on that specific layer and export the result to a .csv file. With this data I compute the shape centers.
I would like to automate this in a macro or script. Could it be that this kind of functionality is already available or if not, could someone point me to a good starting point and efficient methods I should be using. should I recursively search through the cell hierarchy or also code some sort of 'merge layer' step.
In addition, it would be nice to also store a screenshot(.png file) of the GDS layout around every found shape.
many thank!!
Comments
Hallo,
Code for generating a screenshot can be found here: http://www.klayout.de/useful_scripts.html#screenshot.lym
Fetching the shapes is easiest with the RecursiveShapeIterator object:
The RecursiveShapeIterator just delivers the shapes plus a transformation which transforms the shape into the top cell. It does not do the merging. To iterate, merge and flatten, the following code can be used:
Beware that calling "merge" on huge layouts may take some time and require some memory. In addition, "merge" will not maintain shape identities (paths are converted to polygons) and texts will be omitted. If you want to exploit the shape identity, the above code is the better choice.
Matthias