It looks like you're new here. If you want to get involved, click one of these buttons!
Klayout Version = 0.28.12
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.
import pya
mw = pya.Application.instance().main_window()
#lv = pya.LayoutView.current()
lv = mw.current_view()
#lv.clear_selection()
lv.select_all()
print(f'selection_size = {lv.selection_size()}')
Comments
In fact, it seems the lv.select_all() actually clears the selection !
You're right. Looks like "select_all" does not really select "all". I need to debug this. If you like, you can raise a ticket on GitHub: https://github.com/KLayout/klayout.
Till then, I suggest to use
which is essentially the same function than "Edit/Select All".
Matthias
Morning Matthias, Thanks for the workaround. Much appreciated.
Ive filed the issue/ticket on gitlab. Let me know if i have'nt done this correctly.
FYI, i also just tested it on KLayout v29.4 and its the same result
Also, cm_select_all() method is deprecated in version 0.27. I assume i should be using "call_menu('cm_select_all')" instead ?
Finally, and more worryingly, mw.cm_select_all() doesnt seem to select all the objects that i can select manually in the KLayout GUI.
Link to closed gitlab ticket issue:
https://github.com/KLayout/klayout/issues/1823
Servus Matthias,
Thanks for your patience with my radio silence as i was diverted to firefighting a bunch of other issues in our flow.
THANK YOU SO SO MUCH for v0.29.6 !!! I confirm the fixes are working on a number of errors i had applied them to.
I also managed to get your GDS merge suggestion, but as suspected, this smashes the hierarchy, especially the pcells which i would've like to avoid if possible. In my script, i check the identity, position, bbox, rotation and pcell info if it is one, and then simply remove duplication of objects if they all match.
I have one final question related to this topic please ?
Thanks again for all your help. I am sincerely in gratitude of your debt.
Faisal
I posted a reply on Github. I do not fully understand what you try to do, but I feel that you are looking for something like the
RecursiveShapeIterator
.Matthias
I don't know nuthin' from scripting but are you sure that
instances and layers are "valid"/ selectable, either as a
default on startup / layer-gen-from-readin or asserted?
Is "one" object selectable under same "preamble"?
I am also guessing
I am reading this as a request to see "all" shapes with the cells they appear in. This is basically what the RecursiveShapeIterator delivers. While you read out the shapes, it walks through the hierarchy, visiting cells potentially many times. On every step you see the shape, the cell path that leads to the shape (a chain of instances) and the cells involved. So when you do that iteration, you get the same thing than "select all" will give you, but in a one-by-one fashion.
This is not a GUI concept, but on the scripting side a very useful feature.
Matthias