Rotate cell in batch mode

edited January 2013 in Ruby Scripting
Hi, Matthias,

I want to do following actions on a cell

1. load the cell in a new layout
2. rotate the cell 90 degree
3. flatten the rotated cell
4. make cell of the flattened one
5. save it as a new file

Because I want to do the above action on hundreds of cells, could you please teach me how to meke it works with batch ruby script?

Regards,
Canny

Comments

  • edited November -1

    Hi Canny,

    here's a piece of code that reads a layout (here: "x.gds"), creates a new top cell (here: "ROTATED") which rotates the original cell by 90 degree, flattens that cell and writes the output (here: as "x_rotated.gds")

    Please note that this script does not work as expected when the input contains more than a single top cell:

    ly = RBA::Layout::new
    ly.read("x.gds")
    
    top_cell = nil
    ly.each_top_cell { |t| top_cell = t; break }
    
    new_top = ly.add_cell("ROTATED")
    ly.cell(new_top).insert(RBA::CellInstArray::new(top_cell, RBA::Trans::new(RBA::Trans::R90)))
    
    ly.flatten(new_top, -1, true)
    
    ly.write("x_rotated.gds")
    

    Regards,

    Matthias

  • edited November -1
    Hi, Matthias,

    Thank you, klayout ruby script is always helpful for layout handling.

    Regards,
    Canny
Sign In or Register to comment.