Check on empty cell/Layers in GDS

Dear Matthias,
1) May I know how to find the Empty Cell/Layers when we open the existing GDS, I understand when we re-extract or save the file by Don`t write empty cells. kindly guide me.


  • @Kumaran : This Python code seem to do the trick:

    if is not None:
        ly =
        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 {} is empty")

    If you put that in a file in the Macro Development editor and run with the layout you are interested in active, you will get a printed list of all cells that do not contain any shapes or any child cells in the console.

    If you need to run this often, you can place it in the Macros meny by appropriate settings under

    Then you might want to report the result in a GUI dialog instead. Checkout the Qt documentation of KLayout to know how to open a window dialog.

  • Dear Ravn,
    Thanks, it works fine, Thanks a lot for the support.

Sign In or Register to comment.