Command Line/Batch mode

edited October 2014 in General
Hi All,
I need to instantiate a cell in a gds in another gds, under the top cell of this one at coordinate 0,0
I'm able to do it using the graphical interface but I would like to do without the gui.. using a script to run in the command line..

How to do it?

Thx,
Salvatore

Comments

  • edited October 2014

    One-liner:

    RBA::CellView::active.cell.insert(RBA::CellInstArray::new(RBA::CellView::active.layout.cell("OTHERCELL").cell_index, RBA::Trans::new))
    

    Multi-liner:

    cv = RBA::CellView::active
    child = cv.layout.cell("OTHERCELL")
    inst = RBA::CellInstArray::new(child.cell_index, RBA::Trans::new)
    cv.cell.insert(inst)
    

    Matthias

  • edited November -1
    Hi Matthias,
    is it possible to run the script without open the gui?
    and how to define the two gds and the coordinates?

    Thx,
    Salvatore
  • edited November -1

    I see ... by "run in command line" you mean "shell", not KLayout's command line ...

    Here it is:

    # run with 
    #   klayout -b -rd file1=a.gds -rd file2=b.gds -rd out=a+b.gds -r merge.rb
    
    puts "Reading #{$file1} .."
    ly1 = RBA::Layout::new
    ly1.read($file1)
    
    puts "Reading #{$file2} .."
    ly2 = RBA::Layout::new
    ly2.read($file2)
    
    # save the top cell - after creating a new cell there are two top cells
    # and "ly1.top_cell" will fail.
    ly1_top_cell = ly1.top_cell
    
    # create a new cell in ly1 which will hold a copy of ly2's top cell
    new_cell = ly1.create_cell(ly2.top_cell.name)
    
    # copy over everything from ly2's top cell to the new cell
    new_cell.copy_tree(ly2.top_cell)
    
    # place the new cell in ly1's top cell
    angle = 0  # (1 = 90, 2 = 180, 3 = 270 degree)
    mirror = false
    x = 0
    y = 0
    trans = RBA::Trans::new(angle, mirror, x, y);
    ly1_top_cell.insert(RBA::CellInstArray::new(new_cell.cell_index, trans))
    
    # save the result
    puts "Writing #{$out} .."
    ly1.write($out)
    

    Matthias

Sign In or Register to comment.