Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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,
Shoval.

Comments

  • I tried and I observe the same. The attribute layer.name 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.

    Matthias

  • edited October 29

    Hello,

    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
        li.next()
      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
    layer.name = "test"
    

    quite practical :smile:

  • edited November 2

    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,

    Matthias

Sign In or Register to comment.