How to write a GDS with some of layers

Hi sir,
I just want to save some of layers into GDSII file
I knew that should using add_layer in the option of write command like below ,
But it is not workable.
Could you please let me know what is error in my code?
Thanks.

mw = RBA::Application::instance.main_window
mw.layout
view = mw.current_view

layoutfile = RBA::Application::instance.main_window.current_view.active_cellview.name
opt = RBA::SaveLayoutOptions::new
opt.format = "GDS2"
opt.keep_instances=true
opt.no_empty_cells=true
opt.gds2_max_vertex_count=4000
###################################################
ubm_index=0
layoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout
  layoutView.layer_indexes.each do |layer_index|
  layer_info = layoutView.get_info(layer_index)
  if layer_info.to_s.match("152/1") then
  puts "The #{layer_index} mapping to #{layer_info}"
  opt.add_layer(layout.layer(layer_index),layer_info)
  end
 end

 layout.write("3361277.gds",opt)

Comments

  • Hi jiunnweiyeh,

    An additional opt.deselect_all_layers line before you loop through layers should solved the issue.
    By default all layers are being selected during saving, you'll need to deselect them and add layers back like your example.

  • Hi @RawrRanger and @jiunnweiyeh,

    That is correct, but actually the first "add_layer" would automatically imply "deselect_all_layers". So it is needed if the condition never matches. Maybe there is no layer "152/1" (or it is empty) in your case?

    Matthias

  • Hi @Matthias
    151/1 is not empty layer , and I got thse error message...
    base on this code.

    layoutfile = RBA::Application::instance.main_window.current_view.active_cellview.name
    layoutLibrary = RBA::Application::instance.main_window.current_view.active_cellview.filename
    currentfilepath=layoutLibrary.sub(layoutfile,"")
    
    
    layoutfile = RBA::Application::instance.main_window.current_view.active_cellview.name
    opt = RBA::SaveLayoutOptions::new
    opt.format = "GDS2"
    opt.keep_instances=true
    opt.no_empty_cells=true
    opt.gds2_max_vertex_count=4000
    opt.deselect_all_layers
    ###################################################
    ubm_index=0
    layout = RBA::CellView::active.layout
    
    layoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout
      layoutView.layer_indexes.each do |layer_index|
     layer_info = layoutView.get_info(layer_index)
     puts layer_info.to_s
     if layer_info.to_s.match("152/1") then
      opt.add_layer(layout.layer(layer_index),layer_info)
      end
     end
    ######################################################
    date_time=Time.new
    year=date_time.to_s.split(" ")[0].split("-")[0]
    mount=date_time.to_s.split(" ")[0].split("-")[1]
    day=date_time.to_s.split(" ")[0].split("-")[2]
    devicename="Try"
    layout.write("#{currentfilepath}#{devicename}_dTRA_#{year}#{mount}#{day}.gds",opt)
    RBA::MessageBox.info("saved","please check with GDS :#{currentfilepath}#{devicename}_dTRA_#{year}#{mount}#{day}.gds", RBA::MessageBox.b_ok)
    

  • Hi All,
    I got the answer , the code should be change to

    opt.add_layer((layer_index),layer_info)

Sign In or Register to comment.