How to change some pattern(from source layer) into target layer?

Hi Sir , I want to insert some of pattern in source layer. and change the layer to target layer ,
but the code below can't work . could you please help it ?
Thanks.

    LayoutLibrary = RBA::Application::instance.main_window.current_view.active_cellview.name
    current_work_cell= RBA::Application::instance.main_window.current_view.active_cellview.cell_name
    LayoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout
    process_cell = LayoutView.cell(LayoutView.cell_by_name(current_work_cell))
    sourcelayer=input(94,0)        
   ##(soruce layer have many shape/polygon in this cell / other cell)
   ##But I just want to change the layer of shape in current cell.

   targetlayer='93/0' 
    LayoutView.layer_indexes.each do |layer_index|
    layer_info = LayoutView.get_info(layer_index)
     if layer_info.to_s.match(targetlayer)  then
       sourcelayer.data.each do |xx|
          process_cell.shapes(layer_info).insert(xx)
          end  ###for data.each
     end  ## for if 
    end  ###for layer_indexes.each

Comments

  • It's process_cell.shapes(layer_index) (not "layer_info").

    But the script is weird. It's very complex - e.g. LayoutView is not a LayoutView, process_cell is simply RBA::Application::instance.main_window.current_view.active_cellview.cell, the whole thing is partly DRC, partly script etc.

  • Hi Matthias,
    Thanks. it is workable.
    by the way , do you have idea for that ?
    1.read a GDS file from network path (it maybe //etc/library/gds/module.gds)
    2.copy the cell named "module-1" from the file from item1 into current library.
    how to do this request in Ruby?

  • Maybe looking at the sequence of events in interactive
    would help? Even more so, if there were an output log that
    puts the commands executed, out in Ruby or Python syntax.

    (Layers) show only selected
    Select All
    (Layers) pick target layer
    (Edit>Selection) Change Layer

    In fact if I had to do this a limited number of times I
    wouldn't bother scripting it. Well, I wouldn't anyhow
    since I'm fairly bad at coding.

    Can you build macros by recording GUI events? Hmm....

  • as this code , I can open GDSII file , but I can't copy cell (in the SMEE file) into current library

    input_file = "D:\\SMEE.gds"
    mw = RBA::Application::instance.main_window
    mw.load_layout(input_file, 1)
    view = mw.current_view
    cell = view.active_cellview.layout.cell_by_name("SMEE")
    view.select_cell(cell, view.active_cellview_index)
    
  • I found this old post regarding that topic: https://www.klayout.de/forum/discussion/comment/2279#Comment_2279

    The key method is "Cell#copy_tree".

    Matthias

Sign In or Register to comment.