get the subcell with specific layer/cell

edited June 2020 in Python scripting

Hi Matthias,
I would like to get the cell/subcell, whcih contain specific layer/cell (say contact/contact base cell), then how can I get these cell/subcell easily? Thanks.
For example, the Top cell, Subcell2, Subcell4 should be get for below figure:

BG,
KM

Comments

  • Hi KM,

    here is a custom query for "Edit/Search". It looks for cells who have something on layer 4/0 and reports the cell names:

    cell * where cell.shapes(<4/0>).size > 0
    

    Matthias

  • edited June 2020

    Thanks Matt,
    I tried in GUI mode, it work. I'm wonder
    1. if it can ran in python script?
    2. Or run it in batch mode?

    BG,
    KM

  • Hi KM,

    it's easier for me if you tell me from the beginning that you look for a Python solution.

    The Python way is:

    import pya
    
    ly = pya.CellView.active().layout()
    search_for_layer = ly.layer(4, 0)
    for c in ly.each_cell():
      if c.shapes(search_for_layer).size() > 0:
        print(c.name)
    

    Matthias

  • edited June 2020

    Thanks Matt.
    I got the cell list, where the cells contain layer(4,0).
    And I would like to get the direct cell list, where the cells contain specific cell (contact cell - "cnt").

    BG,
    Man

  • edited June 2020

    So you want the cells which call the cells you found in the loop above?

    That concept is called the "parents" of a cell.

    To get the parents for one contact cell ("c" as in the sample code above), this loop will get you the parent cells:

    for p in c.each_parent_cell():
      # each_parent_cell delivers cell indexes. To get the Cell object use:
      parent_cell = ly.cell(p)
      print(parent_cell.name)
    

    Matthias

Sign In or Register to comment.