Python import GDS file's

So I am using the following code I came up with the import GDS files,
it uses a GUI to select the files ..
All works well the first time ,
but when you run the script again ,
to select new cells .
it loads the previous cells as well.
issue seems to be with the tc = layout.top_cells()


for cell in gdsFiles: layout.read(cell) tc = layout.top_cells() for cell in tc: #we don't want to insert the topcell itself if (cell.name != "TOP"): print('New Cell generated: '+cell.name+' in Hierarchy '+topcell.name) trans = pya.CplxTrans( 1.0, ang, flip, x, y) new_instance=pya.CellInstArray.new(cell.cell_index(),trans) print(trans) layout.cell(top_cell_idx).insert(new_instance) x = x + step

Comments

  • This is weird. Basically after you have inserted the cell instances, "layout.top_cells" should give you only a single cell.

    You can print the number of top cells after the loop to verify this.

    You should also check if:

    • "topcell" is really the top cell
    • "gdsFiles" is not containing the old files too
    • "top_cell_idx" is the same than "topcell.cell_index()"

    Matthias

  • edited May 3

    @Matthias
    I have done this above as a debug.
    There is some Ruby code in the fourms that does a similar thing .
    https://www.klayout.de/forum/discussion/735/merge-multiple-gds-files-to-one-parent-cell#latest
    it's not an issue just something I noticed
    Tracy

Sign In or Register to comment.