It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
I am trying to split a certain cell hierarchy from a gds/oasis file into a separate file but my script is hanging:
#Copy a cell/subcell to new layout file
#klayout -b -r ./split.rb -rd src_cell=cell1 -rd input=./top.oas -rd output=out.oas -rd dest_cell=cell2
ly = RBA::Layout::new
TOP = $src_cell
DEST = $dest_cell
if defined?($input)
ly.read($input)
else
abort("ERROR: Primary layout file was not defined!\n")
end
cell_index = ly.cell(TOP).cell_index
if cell_index.nil?
abort("ERROR: Failed to find top cell!\n")
end
cell = ly.cell(cell_index)
ly2 = RBA::Layout.new
ly2.add_cell(DEST)
ly2.dbu = ly.dbu
top_index = ly2.cell(DEST).cell_index
top_cell = ly2.cell(top_index)
top_cell.insert(RBA::CellInstArray::new(cell.cell_index, RBA::Trans::new(RBA::Point::new(0, 0))))
options = RBA::SaveLayoutOptions.new
ly2.write($output, false, options)
Any ideas what I am doing wrong ? Also, is there a better way of doing this ?
Thank you in advance!
Comments
Not sure if I understood everything, but I think
Cell
s belong to a single layout and you cannot add a cell instance into the second layout by referring the cell by its index in the first layout. I guess you can copy theCell
from one layout to other usingCell.copy_tree
. Something liketop_cell.copy(cell)
.I've got no advice for you about scripting, but why not just
make a copy, open the layout, put the Navigator pane visible
and use the Delete Cell, Deep Delete function to remove
everything you don't want from the database?
If the layout is nicely hierarchical maybe exporting the
cell (and hierarchy below) that you want to keep to a new
GDS file could also be a way to go, leave what you don't
want behind.
@world_locus Like jheinsoo pointed out, you can't cross reference a cell into a different layout.
I see you're trying to extract a sub-cell from a layout, right? So you need the additional top cell you built?
Couldn't you just use "Save selected cell as" from the cell list context menu? The script equivalent is
Cell#write
. If you want DEST to be different from TOP you can simply rename the cell before writing.BTW: your script is overcomplicated:
boils down to simply:
and
is
Matthias