Script only detecting a box in some layers

Hi,

I have a puzzling behavior in which I try to manipulate some layout objects in a Python script. First I try to detect certain objects in a cell using

view = pya.Application.instance().main_window().current_view()
layout = view.cellview(0).layout()
cell = view.cellview(0).cell

for idx, layer in enumerate(layout.layer_infos()):
    for shape in cell.each_shape(idx):
        print(cell.name, shape)

The strange thing is that if I have a single box in my cell, it will be found for some layers, but not for some!?! I am sure I am doing something wrong, but cannot figure out what it might be. In the attached files, running the script on the found-file lists one file:

TOP box (-283953,-228147;283953,228147)

And in the other, nothing?! To my understanding, both files contain a box on the same layer, 4/0. So, in this example, the box is in the same layer, to my understanding. However, if I move the box to another layer in the not-found file, it can be found there too it seems...?

Thanks for any help!

Comments

  • Hello @ravn
    I did a simple trial, it worked fine under 27.13 version, even caught the tiny one in layer 10.

  • Ah, found it. There is an error in my code. I must use the layer_indexes to get the correct number. This code works:

    view = pya.Application.instance().main_window().current_view()
    layout = view.cellview(0).layout()
    cell = view.cellview(0).cell
    
    for idx, layer in enumerate(layout.layer_infos()):
        for shape in cell.each_shape(idxs[idx]): # <==== Here is the update.
            print(cell.name, shape)
    

    Thank you @Vincent Lin for helping tracking this.

  • Very good, thanks @Vincent Lin for helping.

    I think your code lacks a line which fetches "idxs".

    Actually, layer_indexes and layer_infos correspond. The "layer index" is not a sequential number as there are hidden layers (e.g. for the PCell guiding shapes) which are not seen in the layer list but have a layer index.

    Python should allow to iterate over both lists this way:

    for idx, layer in zip(layout.layer_indexes(), layout.layer_infos()):
       ...
    

    Matthias

Sign In or Register to comment.