If you save the following script in a file called "cell_layers.rbm" in the same directory as the KLayout installation with the program klayout.exe, you will get it int the tools menu. It also save the layers in a file called "cell_layers.txt" in the same directory as your GDS2 file.
Laurent
#
# DESCRIPTION: Compute and output the layers list of a cell
#
# Run the script with
# klayout -rm cell_layers.rbm ...
# or put the script as "cell_layers.rbm" into the installation path
#
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_layers_handler = MenuAction.new( "Cell Layers List", "" ) {
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"
text += "Layers List :\n\n"
cv.layout.layer_indices.each do |layer_id|
layer_info = cv.layout.get_info(layer_id)
lp_found = nil
iter = view.begin_layers
while !iter.at_end?
lp = iter.current
if lp.layer_index == layer_id
lp_found = lp
end
iter.next
end
if lp_found.nil?
text += "#{layer_info.to_s}\n"
else
text += "#{layer_info.to_s} : #{lp_found.name}\n"
end
end
RBA::MessageBox::info("Cell Layers", text, RBA::MessageBox::b_ok)
# save the data in the file :
File.open(File.join(File.dirname(RBA::CellView::active.filename), "cell_layers.txt"), "w") do |file|
file.puts(text)
end
}
app = RBA::Application.instance
mw = app.main_window
menu = mw.menu
menu.insert_item("tools_menu.end", "cell_layers", $cell_layers_handler)
Comments
Hi Luciano,
there is a similar post here: https://www.klayout.de/forum/comments.php?DiscussionID=1062&page=1#Item_5.
Here is a similar example in Ruby:
Regards,
Matthias
If you save the following script in a file called "cell_layers.rbm" in the same directory as the KLayout installation with the program klayout.exe, you will get it int the tools menu. It also save the layers in a file called "cell_layers.txt" in the same directory as your GDS2 file.
Laurent
Laurent, but if I would like run script on this way
klayout -e mygdsfile -r cell_layers.rbm
and automatically create the file cell_layers.txt
how can modify the rbm script?
Many thanks in advance
Regards
Luciano
Laurent
Hi,
first, please use the ".rb" extension for your script - ".rbm" is deprecated.
You can use this script ("script.rb"):
And use it like this:
Matthias