cannot change cell name

hi @Matthias ,

When some cells created from a library, and open again without that library, the cell names "cell1" changed to "<defunct>cell1"
I want to update the cell names to remove "<defunct>".(I do not want the referred library, I only want to change the cellname back)
However with the following codes, I find newName already removed "<defunct>", but a.name cannot be assigned the new name, its name is still the old name with "<defunct>".

What is wrong with my code?

Anothe question is if with the refered library, the cell structure will be:
TOP
->library1.cell1

Is there anyway to remove the library1, make the structure changed to:
TOP
->cell1

Thank you very much!

cv = RBA::CellView::active
ly = RBA::CellView::active.layout
cell_list = []
for a in ly.each_cell do
  if /^<defunct>CellName/.match a.name then
   newName=a.name
   newName["<defunct>CellName"]="CellName"
   print("newName:",newName,"\n")
   a.name=newName
   print("aName:", a.name,"\n")
   end 
  #end if
  cell_list << a.name
   end
 #end  for
print(cell_list)
print "\n"

Comments

  • edited January 2022

    Hello,

    The <defunc> message means that KLayout knows the cell should come from a library, but that library is not available. This information is not part of the cellname, but knowledge that KLayout has about your cell. It keeps this knowledge to be able to restore the link to library when it's available again.

    What you need is a way to disconnect a cell from a library. This is done by converting a cell to a "static" cell. "static" here is a synonym for "local". To convert the cell, use

    ly.convert_cell_to_static(a.cell_index)
    

    Matthias

  • edited February 2022

    hi @Matthias ,
    I tried to print the cell name, it was always with <defunc>, after I used convert_cell_to_static, the structure was still
    TOP
    -><defunc>libname.cell1

    I also found cell_index was always same.

    May I know what is wrong with it?
    How can I remove the libname?
    I would like use layout.read() to merge two GDS files, if cellname are same from the two GDS, the cell will merged.However the cellname in one GDS is <defunc>libname.cell1name and in another GDS is cell1name, they cannot be merged.

    Thank you very much!

    for a in ly.each_cell do
      print("a.name:",a.name," a.cell_index:",a.cell_index,"\n")
      newIndex=ly.convert_cell_to_static(a.cell_index)
      print("newIndex:",newIndex,"\n")
      a=ly.cell(newIndex)
      print("a_new_Name:", a.name,"\n")
    end
    
  • edited February 2022

    I'm sorry, the conversion of all cells is a bit more elaborate. "convert_cell_to_static" will just create a new copy, but not replace the cell. Replacing is done by doing the conversion over each instance:

    ly = pya.CellView.active().layout()
    
    for c in ly.each_cell():
      for i in c.each_inst():
        i.convert_to_static()
    
    # remove left-over proxy cells
    ly.cleanup()
    

    This will also convert the cell names and remove the lib name. But still this does not solve the problem as the <defunct> cells apparently are not handled (reasoning maybe like "they are already broken, so why disconnect them ..."). You can call this a bug - I have created a ticket for this problem: https://github.com/qt/qtbase/branches/all?page=2).

    So far, the easiest alternative solution is to save the file without the context: this will leave the basic name. You can do so in a script this way:

    opt = pya.SaveLayoutOptions()
    opt.write_context_info = False
    ly.write("new_file.gds", opt)
    

    Regards,

    Matthias

  • hi @Matthias ,

    Thank you so much!
    Your easiest solution is the best!!!

Sign In or Register to comment.