Get cell name list

Hello, I am working with a GDS compensed by quite a few celss in a tree-like hierarchy.
I cannot find a way to scrip a simple code that parse the gds and gives this list of cell names...
Any help?
MAny thanks
BEst

Comments

  • Hi,

    This is a simple Python script using the KLayout Python Module.
    See https://www.klayout.org/klayout-pypi/ and https://pypi.org/project/klayout/

    import os
    import sys
    from   klayout import db
    
    def DumpCellNames(infile):
        """
        Dump the cell names in the given layout file
        Args:
            infile (str) input layout file name such as in GDS2
        """
        #--------------------------------------------------------------
        # [1] Create an instance of class Layout and
        #     read the GDS2|OASIS file into the layout.
        #--------------------------------------------------------------
        layout = db.Layout()
        layout.read(infile)
    
        #--------------------------------------------------------------
        # [2] Search the layout for the cell names with a glob pattern.
        #--------------------------------------------------------------
        cellNameList = sorted( [cell.name for cell in layout.cells("*") ] )
        print( f"### Number of cells in <{infile}> = {len(cellNameList)} ###" )
        for cname in cellNameList:
            print( f"     {cname}" )
    
    #===================================================================================
    if __name__ == "__main__":
        if not len(sys.argv) > 1:
            print( f"Usage:" )
            print( f"  {os.path.basename(__file__)} input_design_file" )
            sys.exit(1)
        else:
            infile = sys.argv[1]
            DumpCellNames(infile)
            sys.exit(0)
    

    % ./f2749-pypi.py ringo.gds 
    ### Number of cells in <ringo.gds> = 9 ###
         EMPTY
         INVX1
         M1M2
         ND2X1
         NMOS2
         PMOS3
         POLYM1
         RINGO
         TIE
    

  • It would be occasionally useful, if the Cells
    window offered a right-click "print this puppy"
    option (following the choice of display-form).
    To copy-buffer or to chosen-file.

  • Hi,

    you can also get a list of cells using this simple query in "Edit/Search and Replace":

    The "Export" menu in the top right offers a way to export the list to the clipboard or as CSV.

    Matthias

Sign In or Register to comment.