delete specific layer shapes below a hierarchical level

I'm trying to delete all shapes belong to a specific layer within only non-top cells, i.e. all the cells referred by top cells.
I find reference in this forum about how to perform some operations within all cells, such as

    layout = pya.CellView.active().layout()
    for cell in layout.each_cell()
        cell.clear(layer1)

But I don't know how to tell if the cell is a non-top cell that I want to perform this operation to.

Thank you for your help!

Comments

  • @Andy Actually that is very simple: a top cell is one without parents, so you need to check if "parent_cells" is not zero:

    for cell in layout.each_cell():
        if cell.parent_cells() > 0:
            cell.clear(layer1)
    

    For large layouts, it may be more efficient to first collect all cells you want to treat and then clear the layer on these cells. The reason is that "parent_cells" is a computed property and "clear" will make the layout modified. This will trigger re-computation on every parent_cells call.

    cells_to_clear = []
    for cell in layout.each_cell():
        if cell.parent_cells() > 0:
            cells_to_clear.append(cell)
    for cell in cells_to_clear:
        cell.clear(layer1)
    

    Matthias

  • Matthias, Thank you! It works as intended!

Sign In or Register to comment.