Untitled

 avatar
unknown
plain_text
a month ago
2.9 kB
3
Indexable
// Funkce pro vytvoření UI panelu
global proc createSelectionUI()
{
    frameLayout -label "Selection Info" -collapsable false;
        columnLayout;
            // Výpis aktuálně vybraných objektů
            textScrollList -allowMultiSelection true -height 200 selectionList;
            button -label "Refresh Selection" -command "refreshSelectionList()";

            // Menu Select
            text -label "Select Menu:";
            button -label "Select All (Ctrl+Shift+A)" -command "selectAllObjects()";
            button -label "Deselect All (Alt+D)" -command "deselectAllObjects()";
            button -label "Inverse (Ctrl+Shift+I)" -command "inverseSelection()";
            button -label "Quick Select Sets >" -command "showQuickSelectSets()";
}

// Funkce pro aktualizaci seznamu vybraných objektů
global proc refreshSelectionList()
{
    string $selection[] = `ls -selection`;
    textScrollList -edit -removeAll selectionList;
    for ($obj in $selection)
    {
        textScrollList -edit -append $obj selectionList;
    }
}

// Funkce pro výběr všech objektů
global proc selectAllObjects()
{
    select -all;
    refreshSelectionList();
}

// Funkce pro zrušení výběru všech objektů
global proc deselectAllObjects()
{
    select -clear;
    refreshSelectionList();
}

// Funkce pro inverzi výběru
global proc inverseSelection()
{
    string $allObjects[] = `ls`;
    string $selectedObjects[] = `ls -selection`;
    string $inverseSelection[];

    for ($obj in $allObjects)
    {
        if (!stringArrayContains($obj, $selectedObjects))
        {
            $inverseSelection[size($inverseSelection)] = $obj;
        }
    }
    select -replace $inverseSelection;
    refreshSelectionList();
}

// Pomocná funkce pro kontrolu, zda je prvek v poli
global proc int stringArrayContains(string $item, string $array[])
{
    for ($i in $array)
    {
        if ($i == $item)
        {
            return 1;
        }
    }
    return 0;
}

// Funkce pro zobrazení Quick Select Sets
global proc showQuickSelectSets()
{
    string $sets[] = `ls -sets`;
    if (size($sets) > 0)
    {
        select $sets;
        print("Quick Select Sets:\n");
        for ($set in $sets)
        {
            print($set + "\n");
        }
    }
    else
    {
        print("No Quick Select Sets found.\n");
    }
}

// Funkce pro vytvoření a dokování panelu
global proc selectionDockPanel()
{
    if (`workspaceControl -query -exists selectionDockControl`)
    {
        deleteUI selectionDockControl;
    }

    string $panel = localizedPanelLabel("Channel Box / Layer Editor");
    string $dockControl = getUIComponentDockControl($panel, false);
    string $label = "Selection";

    workspaceControl
        -tabToControl $dockControl -1
        -minimumWidth 260
        -label $label
        -uiScript "createSelectionUI();"
    selectionDockControl;
}

// Spuštění panelu
selectionDockPanel();
Leave a Comment