LayoutView.select_all() not working / not selecting anything

edited August 2024 in Python scripting

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

    mw.cm_select_all()
    

    which is essentially the same function than "Edit/Select All".

    Matthias

  • edited August 2024

    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.

  • edited August 2024

    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 ?

    1. Is there a way to select all objects (cells and shapes) from either a Layout class or a Cell Class ?
    2. FYI, There would be several advantages programatically if this was possible as apposed to the current select_all() method from the LayoutView Class !
    3. Currently a number of methods exist ( for example layout.each_cell() or layout.top_cell().each_inst() ) but these return cells not for shapes.
    4. Is there a function from a Layout or Cell Class Objects that would returns all shape objects or both cells+shapes, akin to the LV.select_all() method ?

    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

Sign In or Register to comment.