How could I save to another filename in Ruby script?

edited December 2013 in Ruby Scripting
Hi,Matthias:
I found I cannot save to another filename after Boolean operations. Here is my code:
ac = input("1/0")
po = input("2/0")
gate = po.and(ac)
gate.output("3/0")
ly = RBA::Application::instance.main_window.current_view.active_cellview.layout
p=ly.cell_by_name(0) # <<< Is it the topcell name?
fn = "trial "+p.to_s+".OAS.gz"
opt = RBA::SaveLayoutOptions::new
opt.format="OASIS"
opt.oasis_compression_level=9
ly.write(fn, true, opt)

The view topcell is "L1". I want to save file to "trial L1.OAS.gz". But this script has error on define the p variable. Could you help me to correct my mistake?
Thanks!
arided

Comments

  • edited December 2013

    Hi arided,

    "cell_by_name" returns the cell for a given name. The correct code to get the top cell name would be

    top_cell = ly.top_cell
    fn = "trial"+top_cell.name+".OAS.gz" 
    

    And the active layout can now be obtained somewhat easier

    ly = RBA::CellView::active.layout
    

    All the above requires version 0.23.

    If your intention is to produce another file as output of a DRC rather then writing to your original file, you can also use the "target" feature of the DRC engine. To obtain the current cell name, you can use "source.cell_name":

    target("trial" + source.cell_name + ".OAS.gz")
    ac = input("1/0")
    po = input("2/0")
    gate = po.and(ac)
    gate.output("3/0")
    # write the original layers as well:
    ac.output("1/0")
    po.output("2/0")
    

    Matthias

  • edited November -1
    Hi, Matthias:
    Thank you! I will try to learn version 0.23 RBM again. I found it quite different with old veriosn with layer_process built-in simple script.
    regards,
    arided
Sign In or Register to comment.