-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LayoutView.select_all() not working / not selecting anything #1823
Comments
Thanks for this bug report. The formally correct and non-deprecated way of calling "cm_select_all" is
But there is no difference between this function and using Edit/Select All. So what do you mean exactly by "Also the number of returned items is NOT EQUAL to the manual selection in KLayout gui !!!"? In case you refer to the selection count reported by |
Hi Matthias, Thanks for your patience with my delayed response, but i wanted to be accurate with the information below: If i manually select all objects in a layout, then in my current example testcase, at the bottom KLayout footer info bar, i get 183 reported. If i then deselect, and use the APP menu bar's select all or i use the mw.call_menu("cm_select_all") i get LESS and its 144 ! So as a current workaround, I select all objects in a layout manually and then use either lv.object_selection or [i for i in lv.each_object_selected()] and find the list's length. Please let me know how i might be able to package this up into a self contained test case. We really appreciate your help. Faisal |
I played around to reproduce your issue and there is one thing that is odd about "cm_select_all": as it basically does a "select" with a box equal to the cell's bounding box, it will not capture such texts: Reason is that the text (including the glyphs) has to be enclosed in the selection box. When the text is completely inside the cell box, it is selected with "select all" as well: Maybe you can confirm whether this explains your observations. If so, I can try to fix that in this ticket as well. Thanks, Matthias |
Morning Matthias, Good spot. Its helping me get a better understanding so sincerely appreciated. I confirm that your observations are certainly a part of the issue im seeing at my side, but i think theres more to it than that. My notes below:
My current hypothesis is, yes some text seems to diplay beyond the cell boundary / bbox, but depending on the zoom, if that text is hierarchical in another cell / instance, then it is unaccounted for and thus the total number of selected objects varies dramatically. I am trying to confirm this programmatically (see below) by creating a list of all instances in a layout and then comparing the differences. Ps. If we can get a script to report every selected object hierarchically in different scenarios, then i believe it will help us isolate exactly the problem with cm_select_all, but also kill 2 birds and help me with my remove_duplicates() function. |
I imagine that your design got spoiled when someone used multiple You can see that here: use this file and this script:
You have to use an old version of the klayout Python package, e.g.
The result will be a file called "y.gds" which has 8 instances of the "A" cell instead of one and effectively 16 layer 1 rectangles instead of two. But there is simple fix for that: just convert to OASIS and back to GDS. The OASIS writer strips duplicates during the OASIS repetition generation step:
Matthias |
1. Fixed "LayoutView#select_all" 2. Box selection now will select texts at their origin again: this way it is included in the bounding box. Point mode still takes the text's glyph area.
Fixed bug #1823 (select_all not working)
Got closed automatically when merging the PR. |
Servus Matthias,
Thanks again for all your help. I am sincerely in gratitude of your debt. Faisal |
Sorry, but I don't understand what you're trying. Cells and Shapes are fundamentally different objects, so they should not appear on the same level in any reasonable algorithm. Maybe you look for something like the RecursiveShapeIterator. This iterator delivers shapes, but also allows retrieving the context of the cells. It is called the instantiation path and consists of a series of cell instances leading to a particular shape instance. |
Klayout Version = 0.28.12 (also tested on 0.29.4)
Python Version = 3.11.2
Access method = Macro Development IDE
Please see code below. clear_selection() works if i select all objects manually. However, i cant get the select_all() to select anything. Ive tried accessing the LayoutView in 2 different ways but that made no difference.
NB: in fact lv.select_all() seems to clear the selection !
Workaround suggested = mw.cm_select_all()
Testcase:
The text was updated successfully, but these errors were encountered: