Full layout BBox

Hello,

I have a script that I used for long to draw a box all surrounding the full layout of the active cell.
But something is now wrong and I cannot figure out why cv.layout.is_valid_layer?(li) never pass.
Please, can you help to find the missing instruction to insert the boundary_box ?

Thanks, BRgds,
Laurent

# $description: BBox of the current cell L
# $autorun
# $show-in-menu
# $menu-path: tools_menu.end
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# DESCRIPTION: Compute and output the bounding box of a cell (all layers)
#
# Run the script with
#   klayout -rm cell_bbox.rbm ...
# or put the script as "cell_bbox.rbm" into the installation path (on Unix for version <=0.21:
# set $KLAYOUTPATH to the installation folder).
#

  app = RBA::Application.instance

  mw = app.main_window
  view = mw.current_view
  cv = view.active_cellview
  if !cv.is_valid?
    return
  end

  cell = cv.cell
  dbu = cv.layout.dbu

  # implement undo
  view.transaction("Boundary")
  sel_layers = view.selected_layers
    if !sel_layers || sel_layers.size == 1
      sel_layers.each do |lp|
      li = lp.current.layer_index
      print("layer : #{li.to_s} :  #{cv.layout.get_info(li).to_s}  :  #{lp.current.name}\n")
        if cv.layout.is_valid_layer?(li)
        boundary_box = RBA::Box::new(cell.bbox.p1, cell.bbox.p2)
          cell.shapes(li).insert(boundary_box)
          print("BBox drawn")
        end
    end
    end

  text = "Cell: #{cv.layout.cell_name(cv.cell_index)}\n\n"
  text += "xmin: #{cell.bbox.left*dbu} micron\n"
  text += "ymin: #{cell.bbox.bottom*dbu} micron\n"
  text += "xmax: #{cell.bbox.right*dbu} micron\n"
  text += "ymax: #{cell.bbox.top*dbu} micron\n\n"
  text += "width: #{cell.bbox.width*dbu} micron\n" 
  text += "height: #{cell.bbox.height*dbu} micron\n\n" 
  text += "surface: #{cell.bbox.width*dbu*cell.bbox.height*dbu/1000000} mm2" 

  RBA::MessageBox::info("Cell Information", text, RBA::MessageBox::b_ok)

  view.add_missing_layers
  view.commit
  view.update_content
  view.zoom_fit
Sign In or Register to comment.