Screenshot with all the layer and screenshot only one layer

Hi,
I'm trying to do a screenshot of all the layers of a gds file.
Right now I've managed to take a screenshot but it doesn't contain all the layers. (see code below)

include RBA

tailleX=500
tailleY=500
imgsave=ENV['HOME']+"/imagesGDS/"+File.basename($gdsfile, ".gds")+".png"

if (File.exist?(imgsave))
     exit
end

mw = RBA::Application::instance.main_window
mw.load_layout($gdsfile,1)
mw.current_view.save_image(imgsave,tailleX,tailleY)

I would like to be able to select a specific layer as well as select all the layers if possible.
Thank you.

Comments

  • Not sure this is helpful, but seems a lot simpler to
    just "Show All" or "Show Only Selected" in the layer
    window, and Alt-Pr-Scrn? I mean, even invoking the
    script takes more keyboard / mouse activity than
    that.

    But I'd expect that those menu-clicks have a hook
    somewhere in the pile-o'-functions.

  • Hi, Florent!

    You could access layer properties using LayoutView.begin_layers() that returns iterator. Then <iterator>.current().visible (of LayerProperties type) allows to control visibility.

    For example (sorry for Python-centrism):

    it = current_view.begin_layers()
    while not it.at_end():
           it.current().visible = use criteria for visibility there, for example, based on it.current().source_layer and source_datatype
           it.next()
    
  • edited January 2021

    Okay finally worked my way around this.
    I searched deeper in the forum and found something that works :)
    I'll leave the code here if someone want to use it. (not the cleanest thing I've done)

    include RBA
    
    tailleX=500
    tailleY=500
    imgsave=ENV['HOME']+"/imagesGDS/"+File.basename($gdsfile, ".gds")+".png"
    imgpics=ENV['HOME']+"/imagesGDS/"+File.basename($gdsfile, ".gds")+"_pics.png"
    
    if (File.exist?(imgpics))
        if (File.exist?(imgsave))
            exit
        end
    end
    
    mw = RBA::Application::instance.main_window
    mw.load_layout($gdsfile,0)   # $gdsfile is used in another script
    layer_view = mw.current_view
    layer_view.max_hier
    
    #export an image of all the layers
    mw.current_view.save_image(imgsave,tailleX,tailleY)
    
    view = RBA::LayoutView::current
    
    li = view.begin_layers
    while !li.at_end?
      lp = li.current
      if lp.source_layer == 1 && lp.source_datatype == 0
        new_lp = lp.dup
        new_lp.visible = true
        view.set_layer_properties(li, new_lp)
      else
        new_lp.visible = false
        view.set_layer_properties(li, new_lp)
      end
      li.next
    end
    #export an image of only one layer
    mw.current_view.save_image(imgpics,tailleX,tailleY)
    

    Topic that helped me: changing-the-layer-visibility-by-using-ruby

  • Yes, very good! Thanks for sharing the code! :)

    The trick is "layer_view.max_hier". Without that you just get cell frames.

    Kind regards,

    Matthias

Sign In or Register to comment.