Hi,
I'd like to dump some information associated with cells using RBA (KLyout version is 0.20.0 on 64-bit Ubuntu 9.04).
The below is my Ruby script.
When this script is given to klayout with -r option, a design file "test1.oas" that contains four cells is
normally loaded and views are set as intended.
Everything is fine.
However, the output text file "dump.txt" contains only two lines:
## start dumping 'test1.oas'
## end dumping 'test1.oas'
It looks "each_cell" iterator does not iterate over the
current layout. What is my fundamental misunderstanding
regarding the usage of this iterator?
Thank you.
Kazzz
#---------------------------------------------------------
# Create a new application
#---------------------------------------------------------
app = RBA::Application.instance
#---------------------------------------------------------
# Create a new layout
#---------------------------------------------------------
mw = app.main_window
mw.create_layout(0)
#---------------------------------------------------------
# Set a view and load a layout
#---------------------------------------------------------
datafile = "test1.oas"
view = mw.current_view
view.load_layout( "#{datafile}", true )
view.set_title( "My first test of RBA using #{datafile}" )
view.max_hier_levels=(2)
layout = view.cellview(0).layout
### Fine up to this point ###
File.open( "dump.txt", "w" ) do |fo|
fo << "## start dumping \'#{datafile}\'\n"
layout.each_cell do |cell|
fo.print( cell.cell_index.to_s )
fo.print( cell.cell_instances.to_s )
fo.print( cell.caller_cells.to_s )
fo.print( cell.called_cells.to_s )
fo.print( cell.bbox.to_s )
end
fo << "## end dumping \'#{datafile}\'\n"
end
# run the application
RBA::Application.instance.exec
Comments
Hi Kazzz,
The cell iterator is correct. The problem is that create_layout is creating an empty layout. Because of the second parameter of load_layout (true), the layout that is loaded is added to the view (the first layout still persists). Since the iterator walks over the cells of the first layout (the index of cellview is 0), it reports all the cells of the empty layout - which is basically nothing :-)
I have rewritten the code somewhat to reflect what I think was the intention of the script. Mainly I have fixed the problem of the empty layout and added some nice formatting to the output.
Best regards,
Matthias
Thank you for clarification and rewriting the script, which is what I wanted to do.
I could clearly understand the cause of my problem.
This became a good start point in studying RBA.
Thank you for providing a good tool kit.
Best regards,
Kazzz