Instancing via Ruby

edited May 2014 in Ruby Scripting

I have a gds library file in the usual location (KLayout home folder > libraries) and I can add components from it via the GUI just fine.

Now I make a new layout with one cell called "TOP", and I try to add one of the same library components via Ruby. This script causes KLayout to crash with no error explanation. Note however that if I comment out the last line that it does not crash (but, while it imports the cell it does not instance it on the existing "TOP" cell, because that was the point of the final line).

# Inserts a static cell instance from a standard library
include RBA

layout_view = Application.instance.main_window.current_view
layout = layout_view.active_cellview.layout
dbu = layout.dbu
out_cell = layout_view.active_cellview.cell

lib = Library.library_by_name('LIB')
lib_cell_index = lib.layout.cell_by_name('TEST')

layout.add_lib_cell(lib,lib_cell_index)
cia = CellInstArray.new(lib_cell_index,Trans.new(-100/dbu,0/dbu))

inst = out_cell.insert(cia)

Any ideas?

Thanks,
David

Comments

  • edited May 2014

    Ah! Never mind. I had the same problem I had in a previous post (though I thought I had fixed it).

    Anyway here is the solution:

    # Inserts a static cell instance from a standard library
    include RBA
    layout_view = Application.instance.main_window.current_view
    layout = layout_view.active_cellview.layout
    dbu = layout.dbu
    out_cell = layout_view.active_cellview.cell
    lib = Library.library_by_name('LIB')
    lib_cell_index = lib.layout.cell_by_name('TEST')
    lib_proxy_cell_index = layout.add_lib_cell(lib,lib_cell_index)
    cia = CellInstArray.new(lib_proxy_cell_index,Trans.new(-100/dbu,0/dbu))
    inst = out_cell.insert(cia)
    
Sign In or Register to comment.