Rename Cells false false true rename_cells 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: Rename all cells of a layout # # Run the script with # klayout -rm rename_cells.lym ... # or put the script as "rename_cells.lym" into the installation path (on Unix for version <=0.21: # set $KLAYOUTPATH to the installation folder). # string = RBA::InputDialog.get_string("Specify rename expression", "Use '*' to refer to the original name, '#' to refer to the numeric cell ID.\nFor example, 'A*' will prepend the prefix 'A' to the cell name.", "*") if !string.has_value? return end app = RBA::Application.instance mw = app.main_window view = mw.current_view layout = view.cellview(view.active_cellview_index).layout layout.each_cell do |cell| cell_name = layout.cell_name(cell.cell_index) new_cell_name = string.value.gsub(/#/, cell.cell_index.to_s).gsub(/\*/, cell_name) if cell_name != new_cell_name layout.rename_cell(cell.cell_index, new_cell_name) end end