Iterating through all contacts in a given region

Hi Matthias-

Looking for an python example of how to iterate through all the contacts (in layer 15/0) in a given region (let's say from 1000,1000 to 2000,2000).
Already spent two days on that but no success yet.

Thanks, Itamar

Comments

  • Hi Itamar,

    here is a sample which prints the contacts. It uses a "recursive shape iterator" to capture contacts from child cells too. They need to be transformed to top level if you want them to appear is seen from top.

    ly = pya.CellView.active().layout()
    
    box = pya.Box(1000, 1000, 2000, 2000)
    
    l15 = ly.layer(15, 0)
    iter = ly.top_cell().begin_shapes_rec_overlapping(l15, box)
    while not iter.at_end():
      contact = iter.shape().polygon.transformed(iter.trans())
      print(str(contact))
      iter.next()
    

    Matthias

  • Thanks, much appreciated

Sign In or Register to comment.