It looks like you're new here. If you want to get involved, click one of these buttons!
i have one doubt how to calculate density of layer i write one script that give every layer area now i want to total area of gds and density will be print layer name,area,density in on txt. formate.
import pya
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)
area1 = 0
for cell in KLAYOUT.each_cell():
#print(cell)
for shape in cell.each_shape(layer):
area1 += shape.area()
print(area1)
Comments
HI ajaout,
Please format your code example using Markdown functuon, expecially for python code which requires correct indentation to work properly.
You'll need to put all shapes in given layers into a region and merge shapes to get an accurate result.
Use
cell.begin_shapes_rec
instead ofcell.each_shape
becausecell.begin_shapes_rec
returns a recursive iter, this includes the transformation info for shapes in instance.following code example basically covers the questions from these two repeated post
2438 HOW TO EXTRACT KLAYOUT CONSOLE OUTPUT IN ONE FILE TXT FORMATE.
2439 how to calculate area of my gds by python script.