No internet connection
  1. Home
  2. Macro and Script Help

Selecting one type of track, then adding another type of track to the selection. Script paramater issues.

By Brenden @nednednerb
    2022-10-17 00:46:13.319Z

    Title

    Selecting one type of track, then adding another type of track to the selection. Script paramater issues.

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

    I got this script from the How To forum. It is supposed to select All Tracks in Pro Tools of certain type, specified in the last line, "Audio Track" or "Aux Track" and so on. It works to do that.

    I modified the line

    deselectOthers: true,

    to

    deselectOther: false,

    and I duplicated the script and made one for Audio and Aux tracks and so on.

    When I run one script then the other, it "truly" deselects instead of "falsely" deselects (meaning I run one script Audio Track Select then the other script for Aux Track select, and it's supposed to extend the selection inclusively. I want to select more than one track type in other words by using more than one trigger.

    Are you seeing an error?

    What happens when you run this script?

    The correct intended function occurs when deselectOthers: true, variable/paramater is set. Only Audio tracks are selected. When I use a varied script for Aux Tracks, then the audio tracks get deselected and the aux get selected. I thought that deselectOthers: false, could allow the previously selected tracks to remain selected. Maybe I need another parameter. Should I use the "false" parameter or something else?

    How were you running this script?

    I used a keyboard shortcut within the target app

    How important is this issue to you?

    2

    Details

    {
        "inputExpected": "I got this script from the How To forum. It is supposed to select All Tracks in Pro Tools of certain type, specified in the last line, \"Audio Track\" or \"Aux Track\" and so on. It works to do that.\n\nI modified the line\n\ndeselectOthers: true, \n\nto \n\ndeselectOther: false,\n\nand I duplicated the script and made one for Audio and Aux tracks and so on. \n\nWhen I run one script then the other, it \"truly\" deselects instead of \"falsely\" deselects (meaning I run one script Audio Track Select then the other script for Aux Track select, and it's supposed to extend the selection inclusively. I want to select more than one track type in other words by using more than one trigger. ",
        "inputIsError": false,
        "inputWhatHappens": "The correct intended function occurs when deselectOthers: true, variable/paramater is set. Only Audio tracks are selected. When I use a varied script for Aux Tracks, then the audio tracks get deselected and the aux get selected. I thought that deselectOthers: false, could allow the previously selected tracks to remain selected. Maybe I need another parameter. Should I use the \"false\" parameter or something else?",
        "inputHowRun": {
            "key": "-Mpfwh4RkPLb2LPwjePT",
            "title": "I used a keyboard shortcut within the target app"
        },
        "inputImportance": 2,
        "inputTitle": "Selecting one type of track, then adding another type of track to the selection. Script paramater issues."
    }

    Source

    /**
    * @param{{trackType: 'Routing Folder Track'|'Basic Folder Track'|'Audio Track'|'Aux Track'|'VCA Track'|'MIDI Track'|'Inst Track'|'Video Track'}} trackType
    */
    function selectTracksByType({ trackType }) {
    
        const names = sf.ui.proTools.visibleTrackHeaders.filter(track => {
            return track.title.value.trim().endsWith(trackType)
        });
    
        if (names.length === 0) return;
    
        sf.ui.proTools.trackGetByName({ name: names[0].normalizedTrackName }).track.trackScrollToView();
        sf.ui.proTools.trackSelectByName({
            names: names.map(t => t.normalizedTrackName),
            deselectOthers: false,
        });
    }
    
    selectTracksByType({ trackType: "Audio Track" });
    
    

    Links

    User UID: hMEBO84NZbXqVbqYJzU5ZyTNHGN2

    Feedback Key: sffeedback:hMEBO84NZbXqVbqYJzU5ZyTNHGN2:-NEYOwZVlvZahA_q9oZ2

    Feedback ZIP

    Solved in post #2, click to view

    Linked from:

    1. Select All Tracks
    • 2 replies
    1. Hey @nednednerb,

      What's removing the previous selection is actually line 12, which is:

      sf.ui.proTools.trackGetByName({ name: names[0].normalizedTrackName }).track.trackScrollToView();
      

      For your use case, this line is redundant, so you can go ahead and remove it completely.

      It should work as expected after that!

      Reply1 LikeSolution
      1. Brenden @nednednerb
          2022-10-17 03:59:11.288Z

          Thank you! That does work just as expected. I wondered if another part of the script was making it happen, but I wasn't sure what. Thank you. Without a lot of script experience it can be baffling to backtrack from a script made for a similar but not quite the same purpose.