Ruby scripting, turnoff all layer except two layers in gds file

I would like to turnoff all layer except two layers having pads and die border. I could turn off all layers except one layer with the code below. How can I change this code to turn on two layers

include RBA
myListx = []
myListy = []
ly = CellView::active.layout
ly.read('C:/28200.gds')
view = RBA::LayoutView::current
layer = RBA::LayerInfo::new(12, 0)
li = view.begin_layers

while !li.at_end?
  lp = li.current
  new_lp = lp.dup
  new_lp.visible = (lp.source_layer == 12 && lp.source_datatype == 0)
  view.set_layer_properties(li, new_lp)
  li.next
end

lv = Application::instance.main_window.current_view
lv.each_object_selected {
  |obj|
  shape = obj.shape
  if shape.is_polygon?||shape.is_box?
    # NOTE "transformed" - this transforms the polygon into the current cell
    shape.polygon.transformed(obj.trans).each_point_hull { 
      |pt|
      (x, y) = pt.x*ly.dbu, pt.y*ly.dbu
      myListx << x
      myListy << y
    }
  end
}

puts "#{myListx}", "#{myListy}"

end

Comments

  • Hi!

    I think problem lays in fact that you modify layer properties. You don't need to do so, and li.current.visible = <visibility condition> should be enough for your task.

  • @raji This code works nicely for me:

    view = RBA::LayoutView::current
    li = view.begin_layers
    while !li.at_end?
      lp = li.current
      lp.visible = (lp.source_layer == 33 && lp.source_datatype == 0) || (lp.source_layer == 49 && lp.source_datatype == 5)
      li.next
    end
    
  • Thanks Matthias

  • edited September 2021

    .

Sign In or Register to comment.