It looks like you're new here. If you want to get involved, click one of these buttons!
Hi Matthias (and/or others),
similar to the layer highlighter in this discussion (https://klayout.de/forum/discussion/1697/animation-mod#latest), I would like to construct a routine that does the same for selected cells. I wish to be able to highlight (select) a cell in the cell list/tree, then run a code that
Similar to what is in discussion 1697, I would then cycle through cells if more than 1 were selected.
This will allow us to see where in the layout a selected cell is exactly, even if we're in the top cell and all the way zoomed out. The usual way is to Hide/Show cycle quickly and hope that it flashes somewhere. We don't want the selection border width to be always huge either. The other way is to do this hide/show flashing along the hierarchy tree and work yourself up to the top cell. Neither way is liked much by our users.
Does anyone know how to
Thank you !!!
Thomas
Comments
Hi Thomas
have you considered the instance browser for this case? Select a cell in the tree and use "Tools/Browse Instances" to get a list of cell placements and walk through that.
The highlight style follows the selection, but if that is all you're missing, maybe it's easier to change the C++ code rather then coding the functionality again in Python.
Anyway, if you really want to here are some hints:
Matthias
Hi Matthias,
I have to admit I don't quite get the path assignment thing. I think I am close, but I just don't know how to set up the Path objects for lv.object_selection. Can you give me a hint on how that's done ?
Thanks.
Thomas.
Hi Thomas,
if you don't care about where a cell is selected in the cell tree, you don't need to analyze the fill selected cell path. The last item is sufficient:
But when it comes to displaying the cells in the layout, you'll nee to generate a full instantiation path from each instance of the cell you want to highlight. The easiest way is to recursively walk the "parent" tree upwards from the cell you want to hightlight until you reach the current top cell (or skip that path if it ends somewhere else). The selected instance path is basically the reverse of the parent path. You also need to consider that some instances are arrays and you need to decide if you want to highlight all the expanded instances of those.
You're sure you don't want to use the instance browser?
Matthias
Hi Matthias,
I spent the whole day on this and I got to the same conclusion as you: I need to find all the instances of the selected cells, then build paths that describe TopCell-->ThatCell, and hand that to lv.object_selection. I came up with a good way of finding the instances recursively in getInstanceElements(), but I am having a hard time piecing together the paths to the top cell. The application crashes if lv.object_selection = objectInstancePaths has only the target cell instanceElement in it.
getInstanceElementsToTop() is what I am struggling with. I suppose the actual pathway to the top is not so important but since the path needs instanceElements, I don't really know how to convert what I encounter to instances, as I walk up the ladder. And you're right, there could be paths that dont end up at the top cell. Therefore, I need to look at all paths and pick the first that gets all the way up there. Also, if the topcell needs to be an instanceElement as well, I don't know how to get that info from the top cell either :-(
I saw that there is RecursiveShapeIterator.path that gives me a path of a shape, but there is no Cell.path. Does the code for RecursiveShapeIterator.path have the construct for Cell.path in it ? Maybe I could make use of that ?
Also, I was contemplating drawing a shape on a dummy layer into the cell instance, and using RecursiveShapeIterator.path to get the path that I so desperately need, and the just delete the drawn shape. If there are shapes already in the cell instance, then I could also just grab the first one.
Is the path of a shape in a cell instance just +1 longer than that of the cell instance ?
Thanks.
(this is confusing)
Thomas.
Hi Thomas,
the actual path to the top is important if you want to highlight all instances. I think that highlighting just one instance isn't giving much benefit.
I see that the default constructor of "ObjectInstPath" isn't explicitly listed, but you can create one if you fill it's attributes manually. Here is some code which selects all instances of "CELL_TO_HIGHLIGHT" in the current cell.
BTW: for some reason in my installation, "LayoutView#clear_selection" crashes. I need to debug this.
Matthias
Hi Matthias,
thank you soooo much for this. This works nicely. I was wracking my brain on this one.
I know the GUI cannot even do that, but is there a way to select an array ? I noticed that this code only selects the cell instance, not the entire array if the selected cell turns out to be placed as an array.
Thanks.
Thomas.
Well, if anyone is interested, here is the full code. It is helpful when troubleshooting layouts. However, a warning is in order. It does take a long time if a cell is selected that is placed a lot of times in the layout (meaning hundreds of times - like via cells for example), since all possible paths of all instances are being collected. Not attached is the icon that I used (cell_highlighter.png).
Hi Thomas,
very good. Thanks for providing the code!
Matthias
Just FYI, the paths were found from the selected cell to the top cell. This turned out to be wrong, because the user may be in another cellview (not the topcell). This means that unless you're in the topcell, it will highlight the selected cells in wrong places (where there are no cells).
needed to be changed to
and then everything worked ok.
Very good! Thanks for sharing
Matthias