Sort layers by name

Hi Matthias,

Is there an easy way (method available) to sort the layers in the "Layers" window (RMB > Sort By > Name) by code?

Cheers,

Tomas

Comments

  • Yes, there is such a way:

    pya.MainWindow.instance().call_menu("cm_lv_sort_by_name")
    

    Matthias

  • Hello Matthias,

    Thank you! It works great...

    1) How do you use "menu_symbols" to obtain all symbols?

    2) If the "call_menu" pops up a window (like "cm_lv_rename_tab" for example), is there a way to fill in the field and press "OK" by code?

    Cheers,

    Tomas

    1. "pya.MainWindow.instance().menu_symbols()" gives you a list with all symbols (Python)
    2. No, you can't. But "rename_tab" can be simply emulated by using "LayoutView#rename_layer_list"

    Matthias

  • Hi Matthias,

    1) It works fine in Python, but I can't make it work in Ruby:

    RBA::Application.instance.main_window.menu_symbols

    Error > private method `menu_symbols' called for #

    2) Ok, good to know

    Thanks again...

    Cheers,

    Tomas

  • Ruby version is:

    RBA::MainWindow::menu_symbols
    

    and the shorter (and better) Python version (menu_symbols actually is a class method):

    pya.MainWindow.menu_symbols()
    

    Matthias

Sign In or Register to comment.