Find and Delete the Empty cells in the GDS

edited August 30 in Layout

Dear Support team,
May I know how can we delete the empty cells listed? the code can able to list the empty cells that need to be deleted. So can I have your guide thru .

here is the code to find the empty cell.

if pya.CellView.active() is not None:
    ly = pya.CellView.active().layout()
    layers = ly.layer_indexes()
    for cell in ly.each_cell():
        empty = True
        if cell.child_instances() > 0:
            empty = False
        for layer in layers:
            each_shape = list(cell.each_shape(layer))
            if len(each_shape) > 0:
                empty = False
        if empty:
            print(f"Cell {cell.name} is empty")

May I know how to continue deleting the empty cell?
Rgds
KumaranS

Comments

  • An easy way to remove empty cells is to save with empty cells disabled:

    opt = pya.SaveLayoutOptions()
    opt.no_empty_cells = True
    ly.write("layout.gds", opt)
    

    If you want to do that explicitly, why not using "is_empty" on the Cell?

    So eventually this problem is solved by this single line of code:

    ly.delete_cells([ c.cell_index() for c in ly.each_cell() if c.is_empty() ])
    

    Matthias

  • Hello Matthias ,
    It's working, Thanks for the suggestion and the 1 line code. That helps a lot.
    May I have a request to integrate the code, first we need to display the empty cells and the count then we need to delete the cell and display the deleted count.
    As we generally won't generate the GDs as we get from the customers and need to do the verification only. so Kindly can I have your guide thru.
    Rgds
    KumaranS

  • @Kumaran I'm sorry, but I don't fully understand. What exactly is your request? A new feature? Like "remove all empty cells"?

    Matthias

  • Hello Matthias,
    Thanks for the prompt reply,
    yes removal of empty cells, but prior to that we need to list down the empty cell names and their total count, then we remove the empty cells and display the count of the empty cell deleted which should tally before and after the removal of empty cells.
    Hope I made my statement clear, kindly let me know for any clarifications. Thanks for the support.

    Rgds
    KumaranS

  • Thanks for the explanation. But honestly such a feature can be scripted by yourself for your specific purpose. I think it is a bit too specialized to be considered a generic feature request.

    Matthias

Sign In or Register to comment.