How to copy cell from opened gds to new layout

Hi Matthias,

I would like to copy the specified cell A in the GDS file to another empty layout using Python.
(Finally, it is to create CellInstArray for cell A in new empty layout. I understood that in order to create CellInstArray, the cell to refer to must be in the same layout object. Please let me know If I am mistaken.)

So I found a similar question in the forum.

However, I wonder if a new one-line copy method has been created, not a solution using a clip box.
Do I still have to use the clip box?


  • You can do this in two lines:
    1. Save the cell A as OASIS file from the old layout
    2. Read the OASIS file into the new layout
    Note that this copies not only cell A but also all sub-cells of A. So if you do this into an empty layout there are no issues, but if you do it again for a cell B you would need to specify what to do if some sub-cells already exist in the new layout. E.g. overwrite, see the method with the LoadLayoutOptions object, specifically cell_conflict_resolution.

  • @ejprinz Thank you for this explanation :)

    @thor If you want to avoid the trip through a file, you can use an integrated script like this (without clip box):

    # sample layout from here:
    ly_source =
    # specify your source cell here:
    src = ly_source.cell("INVX1")   
    ly_target =
    copy_of_src = ly_target.create_cell(
    new_top = ly_target.create_cell("NEW_TOP")
    # create a 10x10 array with array span vectors (0,10um) and (10um,0)
    new_top.insert(pya.DCellInstArray(copy_of_src, pya.DTrans(), pya.DVector(0, 10.0), pya.DVector(10.0, 0), 10, 10))
    # show the new cell = new_top


  • edited March 2023

    @Matthias Thank you very much. I solved the problem easily :smile:

    I have an additional question. Maybe it's a little different from the topic.
    When I create multiple CellInstArray for one cell (if the cell name is AAA),
    "$" marks were added later, such as AAA$1 or AAA$2. Is there a solution to this?
    Or is the creation of multiple CellInstArray for one cell fundamentally prohibited?

  • @thor No, "$" disambiguators are only added if you create two or more cells with the same name. So I assume your code is not just creating a cell instance ("place it"), but somehow creating new cells, all called "AAA".

    Could you paste some example?


Sign In or Register to comment.