How to get polygon/pattern/cell information in a cell?

Hi sir , May I know how to using scripting to get a cell instance / pattern / polygon information?
in DRC function , I knew code as below...


after that , we can get the pattern /polygon data from layer #51/0.
but , this code can get data by layer 51/0 only (what the special layer do I define in the input )
Now , I want to know how the pattern layout/ cell instance in the cell named "Bump".
in the cell , that may have pattern in layer 51/0 or 52/0 ....etc...
Is possible to make a code like...
dbGet Info =[dbOpencell $libname Bump]



by the way , even that , I don't know how to read the layer information in a shape....

sorry to trouble you for that , please help it....

p.s another question about "Help" document , in the document , how to read that ?
When I want to using the document data to get some idea about coding , I can get some table , but no example for that.
if I want to learn Klayout script , how to enter the door?


  • Hi,

    here is some code in Python to print the contents of the current cell:

    # Get currently loaded layout and cell
    # ly is a Layout object:
    # cell is a Cell object:
    # For CellView see: 
    ly =
    cell =
    print("Listing of cell: " +
    # Iterate the instances in the cell
    # inst is an Instance object:
    for inst in cell.each_inst():
      print("Instance of cell " + ly.cell(inst.cell_index).name + " (" + str(inst) + ")")
    # Iterate the layers:
    for layer_index in ly.layer_indexes():
      # layer_info is a LayerInfo object:
      layer_info = ly.get_info(layer_index)
      print("On layer " + str(layer_info) + ":")
      for shape in cell.shapes(layer_index).each():
        # shape is a Shape object:

    I have added some pointers to documentation.

    You referred to DRC scripts - this is something different. If you want to code universal scripts, you should stay on the API level and use Ruby or Python (easier to learn I guess).

    For learning how to code scripts, I can only offer the documentation. Here is the main entry point:


  • Hi Sir,
    Thanks very much for your code.
    I still using (Ruby) DRC scripts to do that and get same result after modify some of code.
    the key will be ly.get_info(layer_index) in this case.
    But , May I know how to get the layer name (not layer number /purpose) when I have a layer_index?

  • @jiunnweiyeh If we're talking about GDS files there is no layer name in the layout database. Layers are only addressed by layer number and datatype number. OASIS has layer names (you can get by asking LayerInfo for the name), but that is an optional attribute and it's usually empty.

    The layer properties from the LayoutView's layer table you cannot access from a DRC script. That's an entirely different domain.


Sign In or Register to comment.