layer name assignment

I'd like assign a layer name for a layer that I created in my python script.
This layer name I want create in such a way that it is stored in the oasis file.

Comments

  • When you create a layer in a Layout object with Layout#insert_layer you can pass a LayoutInfo object with up to three properties:

    • layer and datatype number: mandatory for GDS and OASIS
    • name: the layer name stored inside OASIS

    like this:

    ly = pya.Layout()
    # creates a layer with layer/datatype 1/0 and name "layer1"
    l1 = ly.insert_layer(pya.LayerInfo(1, 0, "layer1"))
    

    Matthias

  • Yes that did the trick. How do I modify the layer name of an already existing layer?

  • You use "Layout#set_info" (https://www.klayout.de/doc-qt5/code/class_Layout.html#k_143) with the layer index and the new LayerInfo object.

    To change just the name, use

    index = ... the index of the layer to change
    info = layout.get_info(index)
    info.name = "NEW_NAME"
    layout.set_info(index, info)
    

    Matthias

Sign In or Register to comment.