# # 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). # class MenuAction < RBA::Action def initialize( title, shortcut, &action ) self.title = title self.shortcut = shortcut @action = action end def triggered @action.call( self ) end private @action end $cell_bbox_handler = MenuAction.new( "Cell Bounding Box", "" ) { app = RBA::Application.instance mw = app.main_window view = mw.current_view cv = view.cellview(view.active_cellview_index) if !cv.is_valid? return end cell = cv.cell dbu = cv.layout.dbu 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" RBA::MessageBox::info("Cell Information", text, RBA::MessageBox::b_ok) } app = RBA::Application.instance mw = app.main_window menu = mw.menu menu.insert_item("tools_menu.end", "cell_bbox", $cell_bbox_handler)