How to erase the specific layer out of specific region with batch rba code?

edited April 2013 in Ruby Scripting
Hi, Matthias,

I gds files whihc top cell are all 10 um x 10 um and cell original points are at left down corner.
The vias(0/0) with size 0.04 um x 0.04 um are randomly on whole top cell.
I want to delete the contacnt out of region 1st corner (4,4) and second corner(6,6).
If it is possible do it with rba code?

Thank you.



  • edited November -1

    Hi Canny,

    Here's a sketch:

    l = ... # Index of layer on which the vias are located
    c = ... # Top cell
    shapes = c.shapes(l)
    region = RBA::Box::new(4000, 4000, 6000, 6000)  # assumes DBU of 0.001 um    
    shapes.each_touching(region) do |s|

    Please note that this will work only in editor mode. In viewer mode, it is not allowed to erase a shape while iterating them.



  • edited November -1
    Hi, Matthias,

    I tried the above sketch, but I can't make it work.
    I have 2 questions,
    1. how do you get the layer index?
    I wrote the command as,0)
    Is it correct?
    2. I still use klayout 0.21.19, when I execute the rba script, the system always feedback
    Ruby error: 'undefined method `shapes' for 70:Fixnum' (NoMethodError)

    The following is the script I tried, thank you.

    layout ="test.gds"),0)
    shape = c.shapes(lay)
    region1 = RBA::Box::new(3908.645, 1169.02, 3912.125, 1173.75)
    shape.each_touching(region1) do |s|

  • edited April 2013

    Hi Canny,

    Version 0.21.19 is quite old. But that is not the reason for the error message. In "cell_by_name" will give you the cell index, not the cell object. To get the cell object from the index, you'll have to use "layout.cell(cell_index)".

    You can get the layer index by searching for the requested layer in the list of present layers. This is done like this:

    lay = layout.layer_indices.find do |li| 
      layout.get_info(li).layer == 0 && layout.get_info(li).datatype == 0
    lay || raise("No layer 0, datatype 0 found")


Sign In or Register to comment.