Creating a layer with a name

Hello everyone,

I am successful in creating layers in my python script, and can, after running it, right-click the layers and rename them. However, I cannot create the layers with a name in the first place.

using the layout.layer(number, datatype, name) doesn't seem to work. I've also failed doing this using a LayerInfo object.
Can you please help?

Thank you very much,


  • I tried and I observe the same. The attribute can be read correctly, but if a new value is assigned to it, this value is not memorized and not shown in the layer panel.

  • Hi all,

    The layout layer names and the names inside the layer list are entirely different things. The layer name in the layout is a database property. The name of the layer in the layer list is for display purposes.

    In GDS you can't write layer names, just numbers. You can create layer with a name, but the layer number is the primary information and as soon as you write the layout the layer name will be lost.

    So if you want the layer to be shown with a name you have to supply a name in the layer list. The best solution is to use a layer properties file with the proper mapping.


  • edited October 2019


    here is a python code that gets the related Display to a given layer (number,datatype)

    def GetDispLayer(num,dt):
      li = pya.Application.instance().main_window().current_view().begin_layers()
      while not li.at_end():
        lp = li.current()
        if((lp.source_layer ==num) and (lp.source_datatype == dt) ):
          return lp
      raise ValueError("Layer " + str(num)+"."+str(dt)+ " Not Found")
    #example of layer handling:
    l1 = layout.layer(1,0) # create layer 1.0
    mw.current_view().add_missing_layers() # add this layer to the display
    layer = GetDispLayer(1,0) # get the handle to 1.0 display
    layer.visible = True = "test"

    quite practical :smile:

  • edited November 2019

    Hi jonathan,

    thanks for sharing this.

    One comment maybe: if you're just looking for a layer, you can simply type the number into the layer list. A search text box will open then (Caution: bindkeys won't open the search box, but trigger the respective function).

    Kind regards,


  • Hi @Matthias ,

    I was looking at this layer search, it is very great, however there is indeed this issue the bindkeys.
    So I was wondering if there is a way to make it always visible from the start-up, or through a command (best case - I could just add a button and feel free to remove it)

    Also so far I am asking:

    • is there also a way to change the default parameters of the search (especially removing the case sensitivity search) ?
    • maybe there is a command to also prefill the search with a * character (this way the following search would be anywhere on the line)?


  • @jonathan This comment might be in a huge delay, but I just wanted to thank you for this brilliant tiny piece of code. Makes my department's life so much better. Used it in a loop:

    for i in range(len(LayerList)):
    layer = GetDispLayer(i,0)
    layer.visible = True = str(i)+"_"+names[i]

Sign In or Register to comment.