Compute total area of selected shapes false false true calc_area tools_menu.end ruby # # 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 area of selected shapes # # Run the script with # klayout -rm calc_area.lym ... # or put the script as "calc_area.lym" into the installation path (on Unix for version <=0.21: # set $KLAYOUTPATH to the installation folder). # app = RBA::Application.instance mw = app.main_window lv = mw.current_view if lv == nil raise "No view selected" end total_area = 0.0 lv.each_object_selected do |obj| shape = obj.shape layout = lv.cellview(obj.cv_index).layout if shape.is_polygon? || shape.is_box? || shape.is_path? polygon = shape.polygon a = polygon.area m = obj.trans.mag * layout.dbu total_area += a * m * m end end RBA::MessageBox.info("Total area", "Total area of selected objects is #{total_area} square micron", RBA::MessageBox.b_ok)