No internet connection
  1. Home
  2. Support

How to set new folder track's color to match color of originally selected track(s)

By Gary Philips @Gary_Philips
    2022-03-23 01:48:19.883Z

    Title

    How to set new folder track's color to match color of originally selected track(s)

    What do you expect to happen when you run the script/macro?

    Could somebody let me know how to edit this script so that the newly created folder track's color matches the color of the originally selected tracks? Thanks!

    Are you seeing an error?

    What happens when you run this script?

    Works great in ProTools 2021.12

    How were you running this script?

    Other

    How important is this issue to you?

    4

    Details

    {
        "inputExpected": "Could somebody let me know how to edit this script so that the newly created folder track's color matches the color of the originally selected tracks?  Thanks!",
        "inputIsError": false,
        "inputWhatHappens": "Works great in ProTools 2021.12",
        "inputHowRun": {
            "key": "-MpfwoFyZNOpBC3X5xGI",
            "title": "Other"
        },
        "inputImportance": 4,
        "inputTitle": "How to set new folder track's color to match color of originally selected track(s)"
    }

    Source

    function makeNewFolder(folderTitle) {
        // Open Move to New Folder dialog and set parameters
        sf.ui.proTools.menuClick({
            menuPath: ["Track", "Move to New Folder..."],
        });
    
        sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
            waitType: "Appear",
            timeout: 2500,
        });
        let folderDlg = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first;
        let popupButtons = folderDlg.popupButtons;
    
        //Assign the buttons coming out of the previous instruction to individual variables
        var folderType = popupButtons[0];
    
        if (folderType.value.invalidate().value != 'Routing Folder')
            folderType.popupMenuSelect({ menuPath: ['Routing Folder'] });
    
        //Now that it's definitely a routing folder we have the other two popup menus available to assign to variables
    
        var folderWidth = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[2];
        var timeBase = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[1];
    
        // Set them accordingly
    
        if (folderWidth.value.value != 'Stereo')
            folderWidth.popupMenuSelect({ menuPath: ['Stereo'] });
    
        if (timeBase.value.value != 'Ticks')
            timeBase.popupMenuSelect({ menuPath: ['Ticks'] });
    
        sf.ui.proTools.windows.whoseTitle.is('Move to New Folder').first.checkBoxes.whoseTitle.is('Route Tracks to New Folder').first.checkboxSet({
            targetValue: "Enable",
        });
    
        sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.textFields.whoseTitle.is('Track name').first.elementSetTextFieldWithAreaValue({
            value: folderTitle,
        });
    
        // Make it so
        sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.buttons.whoseTitle.is('Create').first.elementClick();
        //If there were multiple outputs assigned to any rtrack in the selection we will get a further diaslog
        if (sf.ui.proTools.confirmationDialog && sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("Replace").exists) {
            sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("Replace").first.elementClick();
            sf.ui.proTools.confirmationDialog.elementWaitFor({ waitType: "Disappear" })
        }
        sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
            waitType: "Disappear",
            timeout: 2000,
        });
    
    
    }
    
    function reAssignFolderOutputs(originalOutputs, folderTitle) {
    
        // Refresh PTs track list
        sf.ui.proTools.mainWindow.invalidate();
        //Reselect the new folder
        sf.ui.proTools.trackSelectByName({ deselectOthers: true, names: [folderTitle] });
    
    
        //Assign the folder output to the outputs of the first originally selected track
        //Only allow setting from the output and bus sub-menus to avoid duplication
    
        for (let i = 0; i < originalOutputs.length; i++) {
            if (originalOutputs[i][0] === 'output' || originalOutputs[i][0] === 'bus') {
                sf.ui.proTools.selectedTrack.outputPathButton.popupMenuSelect({
                    menuPath: originalOutputs[i],
                    isControl: i > 0,
                });
            }
        }
    }
    
    function getOutputAssignments() {
        // Set up variables to hold original assignments. NOTE this will only check the top-most selected track
        //Variable to store the current output assignment
        let originalOutputs = sf.ui.proTools.selectedTrack.outputPathButton.popupMenuFetchAllItems().menuItems.filter(mi => mi.element.isMenuChecked).map(ci => ci.names);
        sf.ui.proTools.appActivateMainWindow();
        return originalOutputs
    }
    
    function main() {
    
        // Get Name for New Folder - Keep in mind this will also be the name of the busses used to route the tracks
        var folderTitle = sf.interaction.popupText({ title: 'Name of New Folder' }).text;
    
    
        sf.ui.proTools.appActivateMainWindow();
        // Refresh PTs track list
        sf.ui.proTools.mainWindow.invalidate();
    
        let originalOutputs = getOutputAssignments();
    
        makeNewFolder(folderTitle);
    
        reAssignFolderOutputs(originalOutputs, folderTitle);
    
    
    }
    
    main();
    

    Links

    User UID: SvvTAi4f55Q3ZPiR87JW0e8nJNs2

    Feedback Key: sffeedback:SvvTAi4f55Q3ZPiR87JW0e8nJNs2:-MyoSTEyvkQF383VZ5xm

    Feedback ZIP

    • 3 replies
    1. Gary Philips @Gary_Philips
        2023-10-11 02:10:54.789Z

        Still haven't been able to figure this out so I do it in two steps. One to make the new folder and move the tracks and a second step to load a track preset that contains only the track color. So I have one preset for each of my basic colors and load that via keyboard shortcut once the folder creation scrip is finished. . . .

        1. At present, it's still not possible to get a track's color, so your current approach is the way to go.
          I would suggest using the Set Track/Clip Color macro action, or its script equivalent sf.ui.proTools.colorsSelect, to set the color instead of using a Track Preset, since it will be faster.

          1. Gary Philips @Gary_Philips
              2023-10-12 00:13:43.501Z

              Great tip as always Raphael, thanks. I just re-worked all my color setting shortcuts in that way -- way faster. Thank you!