Scripting the import feature

edited June 2013 in Ruby Scripting
It would be very helpful to be able to script the "Import -- Other File Into Current" function. I tried loading multiple GDS files into the same layout, but they always end up with their own cells at the same level and thus are not really merged. I guess one could then create a new cell and instance the other cells into it, but that is quite complicated and I was hoping one could just call the function used in the "Import" script. Thank you.

Comments

  • edited November -1

    Hi,

    The import basically just adds a new top cell above the imported ones. So it's not difficult to implement that - all you have to do is to create a new top cell and two instances of both original top cells.

    One problem you might encounter is name clashing - if the layouts you load share hold cells with the same name, these cells will be joined.

    Matthias

  • edited November -1
    Hi,

    I'm trying to do a similar thing, merging two (or more) gds files into one layout. To avoid name clashing all cells get renamed after the loading.
    I tried to follow your advice, to create a new top cell and add the original top cells. I'm guessing I'm missing something simple, but how can I refer to the original top cells (as instance ?) ?

    When I use the following loop

    layout.cell(cell_to_insert).each_inst do |inst|
    layout.cell(top_cell_idx).insert(inst)
    end

    it inserts all instances but not the top cell itself.

    Thanks,

    Hannes
  • edited August 2013

    Hi Hannes,

    if you want to import the original top cell as an instance you'll have to create an instance of the new top cell rather than to import the instances of the child cells of the original top cell (that is what you do).

    The corresponding code is like this, provided that the default (unity) transformation is sufficient for the new instance:

    layout.cell(top_cell_idx).insert(cell_to_insert, RBA::Trans::new)
    

    Matthias

  • edited November -1
    Hi Matthias,

    thanks, but I still don't quite get it. What is the type of "cell_to_insert". In the docs I could only find cell.insert versions which need an Instance object/Instance Array object representing the instance. Well, the question is, how do I refer to the original top cell?

    Thanks,

    Hannes
  • edited November -1

    Hi Hannes,

    the object you'll have to insert is a CellInstArray object (this represents single as well as array instances or SREF/AREF's in GDS slang). This object takes a cell index which you can object from the top cell's Cell object with Cell#cell_index plus a transformation (displacement plus rotation or mirroring). Both is required to form a cell instance. That's plain GDS scheme mapped to KLayout's objects, so there is not much magic about that.

    Please note that both the cell where you create an instance and the cell which you instantiate must live in the same Layout object, but I understand that is the case already.

    Matthias

Sign In or Register to comment.