Design size variation when using Save layout options

Hello,

I have a design "test.oas" with a top cell that interest me "Top" and a bunch of other empty topcells.
I try to get rid of other topcells using SaveLayoutOptions, but I am then getting a very large design

if I run the following script:

ly=pya.Layout()
ly.read("test.oas")
lo = pya.SaveLayoutOptions()
lo.add_cell(ly.cell("Top").cell_index())
ly.write("test2.oas",lo)
ly.clear()
ly.read("test2.oas")
ly.write("test3.oas")

I have the following design sizes:
test.oas is 199K
test2.oas is 31M (too large file!)
test3.oas is 174K (what I was hoping to have)

I also tried to change oasis compression level

lo.oasis_compression_level = 10

but it did not change anything.
would you have any idea what I am doing wrong when using Save layout options?

Comments

  • Hi @jonathan,

    "test2.oas" is not an OASIS file, because the default format is "GDS2" in "SaveLayoutOptions". Use "set_format_from_filename" to establish the right format (https://www.klayout.de/doc-qt5/code/class_SaveLayoutOptions.html#k_88).

    Matthias

  • edited August 4

    Thanks! This has solved the issue!

    also providing corrected code:

    ly=pya.Layout()
    ly.read("test.oas")
    lo = pya.SaveLayoutOptions()
    lo.add_cell(ly.cell("Top").cell_index())
    lo.set_format_from_filename("test2.oas")
    ly.write("test2.oas",lo)
    

    test2.oas is 174K

    I have noticed that if I use

    lo.set_format_from_filename("file.oas")  
    

    It also works, so it is not necessary to have the same name as the output file, however

    lo.set_format_from_filename(".oas")
    

    fails and cannot determine the format, but I think it could be a good upgrade to allow this?

    PS:
    I also noted the other solution:

    lo.format= "OASIS"
    

    and sorry for not reading API reference properly as the format info is quite well documented.

Sign In or Register to comment.