Changing the Layer of a Cell

edited March 2013 in Ruby Scripting
Hello Matthias,

I am having some trouble changing the layer of a cell. I am using the "move_layer" command in the Layout Class and specifying the only layer used in the cell for the first argument and the desired layer for the second. I receive this error "Internal error: dblayout.cc:1237src<layers()&&m_layer_states[src]!=Free was not true in Layout::move_layer."
Can you explain my problem?
Thank you.

Jared

Comments

  • edited November -1
    For some reason the layer of the cell that I am trying to manipulate is not valid. I'm not sure how that happens. The cell is called from another GDS file. Is that what makes it invalid, or is it because it was invalid in the previous GDS file?
  • edited November -1

    Hi Jared,

    are you trying to move shapes from one layout/cell to another? That does not work yet. Can you given some sample code?

    Matthias

  • edited November -1
    I am actually reading a GDS file a calling a cell by name with a certain layer (123) and then placing it into a new layout where I am then attempting to change the layer. The cells that are being called are polygons mostly.
    Here is the code:

    module MyMacro

    include RBA

    mw = RBA::Application::instance.main_window
    ok = RBA::Value::new(true)
    echo = RBA::QLineEdit::new

    label = RBA::QInputDialog::getText(mw,"Label","Enter Label Here (Capitals Only)",echo.echoMode,"TEXT",ok)
    if ok.value && !label.empty? # Ensures that nothing will happen if "Okay" hit when no label is input

    m = RBA::QInputDialog::getInt(mw,"Magnification","Enter Magnification Here", 1, 1, 100, 1, ok) # Magnification
    r = RBA::QInputDialog::getInt(mw,"Rotation","Enter Rotation Here (Counter-Clock Wise)", 0, 0, 270, 90, ok) # Rotation
    l = 10000 # 10000 is the original length of character in nm
    w = 7000 # 7000 is the original width of character in nm
    s = (w/4)*m # 4 is ratio of width of character to spacing between characters
    n = label.length # Length of string or the number of characters
    n2f = n/2.floor # 5/2 = 2.5, 2.5(floor) = 2

    ly = mw.create_layout(0).layout
    layout_view = mw.current_view
    #current_cellview = layout_view.current_cellview.layout

    main_top = ly.add_cell("Label")

    ly.read("LABELS.gds")

    if n.odd? # Script for odd number label
    while n > 0
    cell_index = ly.cell_by_name("LABEL_"+label[n-1]) # Gets rightmost string character
    ly.cell(main_top).insert(RBA::CellInstArray::new(cell_index,RBA::CplxTrans::new(m,0,false,RBA::DPoint::new(n2f*(s+w*m),0))))
    ly.flatten(main_top, -1, true) # Positions cells from right to left because n is decrementing
    n = n - 1 # Flatten breaks the hierarchy and then prunes the unnecessary cells
    n2f = n2f - 1
    end
    elsif # Script for even number label
    while n > 0
    cell_index = ly.cell_by_name("LABEL_"+label[n-1])
    ly.cell(main_top).insert(RBA::CellInstArray::new(cell_index,RBA::CplxTrans::new(m,0,false,RBA::DPoint::new((n2f-0.5)*(s+w*m),0))))
    ly.flatten(main_top, -1, true)
    n = n - 1
    n2f = n2f - 1
    end
    end
    prune_cell = ly.cell_by_name("TOP") # Prunes "TOP" cell of read "LABELS" GDS file to remove the unecessary cells
    ly.prune_cell(prune_cell,-1)

    #info = current_cellview.get_info(123)
    #info.layer = 100
    #ly.set_info(123, info)

    if r == 0
    layout_view.select_cell(main_top, 0) # Select the top cell in the view, set up the view's layer
    layout_view.add_missing_layers # list and fit the viewport to the extensions of our layout
    layout_view.zoom_fit
    elsif # Case for when label is rotated
    rotated_top = ly.add_cell("Label_"+r.to_s)
    ly.cell(rotated_top).insert(RBA::CellInstArray::new(main_top,RBA::CplxTrans::new(1,r,false,RBA::DPoint::new(0,0))))
    ly.flatten(rotated_top, -1, true)
    layout_view.select_cell(rotated_top, 0)
    layout_view.add_missing_layers
    layout_view.zoom_fit
    end
    end

    end
  • edited November -1
    The commented portions of code are my latest attempt to change the layers of the called polygon cells that I acquired from you website.
  • edited March 2013

    Hi Jared,

    thank you for the code. I was confused a little because I did not find the move_layer command you were mentioning.

    But I guess I understand the intention.

    To change the layer, you have several options. You're basically right that you can use set_info to change a layer's identity. The code to achieve that looks like the following. It assumes that the shapes you have read are on layer 17, datatype 0 and that they should be mapped to 44, datatype 0. Please substitute the values you require:

    # find the index of layer 17/0:
    input = nil
    ly.layer_indices.each find |li|
      info = ly.get_info(li)
      info.layer == 17 && info.datatype == 0
    end
    input || raise("The label's layout does not contain layer 17, datatype 0")
    
    ly.set_info(input, RBA::LayerInfo::new(44, 0))  # change layer
    

    Another option is to map the layer on reading using the layer mapping feature of the reader. Again substitute the desired values:

    options = LoadLayoutOptions::new
    lm = LayerMap.new
    # the second parameter is a unique identifier for the logical layer. For multiple layers use 0, 1, 2 ...
    lm.map(LayerInfo::new(17, 0), 0, LayerInfo::new(44, 0))
    options.set_layer_map(lm, false)
    ly.read("your_file.gds", options)
    

    Regards,

    Matthias

  • edited November -1
    You are a genius Matthias. Thank you.
    Sorry for the confusion about not having the move_layer function in there. I had removed it to try something else and forgot to put it back.
Sign In or Register to comment.