HOW TO EXTRACT KLAYOUT CONSOLE OUTPUT IN ONE FILE TXT FORMATE.

import pya
import csv
output_file = "/openlane/work/scripts/output.txt"
gds_files = ["/openlane/work/cliped100.gds"]
KLAYOUT = pya.Layout()

for each_gds in gds_files:

KLAYOUT.read(each_gds)
#print("Cells : ",KLAYOUT.top_cell().name)
#print("Layers : ",KLAYOUT.layers())

#print("each",KLAYOUT.each_cell())
for ly_id in KLAYOUT.layer_indices():

#print ("Layer_info: ",KLAYOUT.get_info(ly_id))
layer_name =KLAYOUT.get_info(ly_id)
print('layer_name:',layer_name)
#sh = KLAYOUT.top_cell().each_shape(0)

# print ("shape area : ", sh)
layer = KLAYOUT.layer(layer_name)
#print(layer)
area = 0
for cell in KLAYOUT.each_cell():
#print(cell)
for shape in cell.each_shape(layer):
area += shape.area()
print(area)

In this i want store all area value in one txt formate document.
anyone know this ?

Comments

  • @ajaout You can format code in Markdown with a triple backtick line before and after the code (like on GitHub for example).

    The problem should be easy to solve if you use Python's methods to write to files, like the ones explained here: https://www.askpython.com/python/built-in-methods/python-print-to-file

    Matthias

  • @ajaout
    For python , I can't help you ...but I guess that you can reference for what my code in Ruby.

    layoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout
    dialog = RBA::QDialog.new( RBA::Application.instance.main_window)
    
    log_filename="area.log"
    aFile = File.new("#{log_filename}", "a+")
    
    layer_list= Array.new()
    view = RBA::LayoutView::current
    li = view.begin_layers
    while !li.at_end?
    lp = li.current
    
    layerdata=input(lp.source_layer.to_i,lp.source_datatype.to_i)
    layerarea = layerdata.area.round(3)
    layer_list << "Layer: #{lp.source_layer}//#{lp.source_datatype} , Area : #{layerarea}"
    
    li.next
    end
    
    layer_list.each do |layer_data|
    aFile.syswrite("#{layer_data}\n")
    end
    aFile.close
    
Sign In or Register to comment.