It looks like you're new here. If you want to get involved, click one of these buttons!
Hi all!
I am a beginner in klayout python scripting and as such I believe my question is rather basic.
All I want to do is read an oasis file from disk, create an array of this object (with given number of rows/columns and horizontal/vertical spacing) and save it. From other discussions I have seen that the function pya.CellInstArray should do exactly what I need but I didn't understand how to pass to this function the layout I want to make the array of.
Thank you in advance for you help!
Comments
I though some more detail might facilitate answers: all I want to achieve is the same as what one can do with the "Edit>Selection>Make Array" function of the Klayout editor GUI. I would like the resulting array to be in the same layer and in the same cell of the input oasis file. Thank you
You should first read through the documentation, and get familiar with the API: https://www.klayout.de/doc-qt5/programming/database_api.html
Note that "Make Array" does not produce an "Array Instance".
Olivier
Thank you for your reply! I am looking through the documentation... I see that the CellInstArray is not really what I thought it was. I am trying to achieve the first of the two results you listed ("Make Array"). Could you suggest a way to do it?
Maybe what I wrote was not very clear, but I can say it in a different way: you can create arrays by two different methods, either with "Edit > Selection > Make array" or with a cell by clicking on "Array Instance" in the cell properties.
In a script, I know how to do the latter (create a "CellInstArray"), and I don't know if there's a way to do the former automatically.
I know how to create an array by clicking on "Make array", now i am trying to achieve the same result though scripting. If no function exists for doing this in one step, I expect that something like an iterative loop of copying and pasting the object in the desired array geometry should be possible. So far I managed to read the oasis file, creating the cell object "cell" that are on the layer index "layer_index" and then collecting the shapes with:
shapes = cell.shapes(layer_index)
Now I would like to know how I can add to the object "shapes" itself shifted by (dx, dy). Thank you
If you want to make an array, you'd better build a "CellInstArray".
If you really want to emulate the "Make array", then you should probably duplicate the shapes and translate them (Shape.dup() and Shape.transform()).
Disclaimer: I am a beginner!
I now managed to create a CellInstArray, and then I flattened the layout in order to have one cell only in the output file. Unfortunately I run into memory problems during flattening because my cell is really large. Anyways, thanks a lot for your input! If anyone can suggest a more efficient way to do this without eating up all my memory it would be great.
You need to keep the layout structure as much hierarchical as possible in order to reduce memory consumption. Do not flatten.
I agree with ocasta - arrays are for saving memory. A more efficient way is to use a loop and place the shape multiple times (as suggested by ocasta too).
Maybe going to 64bit helps.
Matthias