Most of effective way of getting box coordinates for a given cell and a given layer.

edited August 2020 in Python scripting

Hello, I am trying to write a script which will have an input of layer name and a cell name, then I want it to return all cOordinates of boxes within the given layer and given cell.

Does anyone have any suggestions from where to start?
For instance I can get all coordinates of boxes for a given cell by using

     my_layout_query=pya.LayoutQuery.new("select cell.name, path_trans * cell.bbox, path_trans.disp.x, path_trans.disp.y from instances of ...*")
     cell_to_iterate='bar'

     for q in my_layout_query.each(layout):  #iterate with cell names
       box_info=q.data()
       if box_info[0]==cell_to_iterate:
         print(box_info[0])

However I am not sure how to get the box/shape coordinates for a specific layer.

Thank you! I really appreciate your help!.

Comments

  • edited August 2020

    I think I found the answer. Hope this helps to any other people who need to do the same task. It is really nice that you can even do it for multiple layers simultaneously! This will give you the absolute coordinates of each shape for a given cell and given layer or layers

    layout=pya.Layout()
    cell=layout.cell('name_of_the_cell')
    iter=pya.RecursiveShapeIterator.new(layout ,cell,[layer_index1,layer_index2])
    
    while not iter.at_end():
      box_in_cell = iter.shape().box
      box_in_initial_cell = iter.trans() * iter.shape().box
      print(box_in_initial_cell)
      iter.next()
    
  • Hi,

    thanks for sharing this solution!

    The code is correct, I just think you wanted to use "box_in_cell" in the following expression like this:

      box_in_cell = iter.shape().box
      box_in_initial_cell = iter.trans() * box_in_cell
    

    Regards,

    Matthias

Sign In or Register to comment.