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
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
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
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:
Another option is to map the layer on reading using the layer mapping feature of the reader. Again substitute the desired values:
Regards,
Matthias
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.
I found the move_layer function works well for this purpose. https://www.klayout.de/doc-qt5/code/class_Layout.html#method117