How to find the coordinates of the shapes touching/overlapping a given box?

edited February 2012 in General
Hi Matthias,

Thanks for the great view/editor. I'd like to find the coordinates of the shapes that are touching/overlapping a given box on a certain layer, say, (0,0, 10, 10), how can I start with? The following script seems to provide some hints but I'm not yet familiar with Ruby. Any suggestions?

http://www.klayout.de/resources/list_layers.rbm

Comments

  • edited February 2012

    Hi,

    the list_layers script is actually a good starting point. You can modify the script to better suit your requirements.

    First you can remove lines 52 to 70 because in that script, a ruler is used to define the search region. If you don't need a graphical way to define the region, you can skip that part.

    The second thing you need to adjust is the search loop. In the original that is line 120 to 157. That will probably look like this:

    search_box = RBA::Box.new(0, 0, 10000, 10000) # 10x10 um in database units for 1nm DBU
    shape_iter = layout.begin_shapes_touching(cell, layer_index, search_box)
    while !shape_iter.at_end
    
      shape = shape_iter.shape
      if shape.is_polygon? 
        # do something with the polygon, i.e. 
        # puts shape.polygon.to_s
      elsif shape.is_path?
        # do something with a path ...
      elsif shape.is_box?
        # etc.
      end
    
      shape_iter.next
    
    end
    

    Finally, the output happens in lines 159 to 187 of the original. Probably you'll need a different kind of output. The example in that script shows how to build a HTML document and display it in a small browser window.

    Hopefully that helps somewhat.

    Best regards,

    Matthias

  • edited November -1
    Hi Mathias,

    Thanks for the suggestion. It should work for me. Looks like I'll have to learn Ruby first. XD
Sign In or Register to comment.