No internet connection
  1. Home
  2. How to

Show/hide and select track error

By David Heylen @David_Heylen5
    2021-05-11 10:11:31.070Z

    Hello,

    I want to show/hide a track and select it.

    I have this script that works but it still gives me a error log :

    SCRIPT :

    
    const trackMatch = sf.ui.proTools.trackNames.filter(x => x.match('MUZIEK galm'))
    
    globalState.showtoggle = !globalState.showtoggle
    
    if (globalState.showtoggle) {
        //  Hide Tracks
        sf.ui.proTools.trackSelectByName({ names: trackMatch })
        sf.ui.proTools.trackVisibilityHideSelected()
    
    } else {
        //  Show Tracks
        sf.ui.proTools.trackShowByName({ names: trackMatch })
    }
    
    
    sf.ui.proTools.trackGetByName({ name: "MUZIEK galm" }).track.trackSelect();
    
    
    
    
    
    

    ERROR in LINE 21 :
    Cannot read property 'track select' of null
    (MUZIEK galm line 18)

    The problem is when track is selected and want to HIDE it again it give me the error

    Greetings, David

    Solved in post #8, click to view
    • 12 replies
    1. samuel henriques @samuel_henriques
        2021-05-11 15:27:42.990Z2021-05-12 09:16:50.104Z

        Hello David,

        If you are trying to show/hide one track named "MUZIEK galm"
        this should work:

        const trackName = "MUZIEK galm"
        
        
        let visibleTracks = sf.ui.proTools.visibleTrackNames
        
        // If track is visible
        if (visibleTracks.indexOf(trackName) >= 0) {
        
          // Select Track
          sf.ui.proTools.trackGetByName({ name: trackName }).track.trackSelect()
          //  Hide Selected
          sf.ui.proTools.trackVisibilityHideSelected({})
        
        } else {
        
        // If the track to show is selected, the command wont work so we need to deselect all tracks, just as safety
          sf.ui.proTools.trackDeselectAll()
          sf.ui.proTools.trackGetByName({ name: trackName, makeVisible: true }).track.trackSelect()
        
        }
        
        

        Let me know if instead you want to show/hide several tracks containing "MUZIEK galm" on the name.

        1. DDavid Heylen @David_Heylen5
            2021-05-11 18:28:30.007Z

            Hello Samuel,

            Thanks for the help but still have a error :

            Could not evoke 'Hide Selected tracks' (MUZIEK galm copy line 12)
            Could not open track list popup menu
            popup menu was not found

            Greetings,
            David

            1. samuel henriques @samuel_henriques
                2021-05-11 18:32:54.527Z

                Could you double check if the track list is open?

                1. DDavid Heylen @David_Heylen5
                    2021-05-11 18:51:13.074Z

                    I always keep it closed when mixing and want it that way.

                    I have a workaround with a extra "hide selected track" macro for now but it would be great if those two buttons go into a toggle.

                    1. samuel henriques @samuel_henriques
                        2021-05-11 19:01:22.092Z

                        ok, cool, but would you mind if the track list opens and closes to show/hide the track, or you would prefer if you never see it at all?

                        But you can confirm the script works if the clip list is open?

                        1. DDavid Heylen @David_Heylen5
                            2021-05-11 19:16:22.562Z

                            It can open/close when showing.

                            I did the test when the track list (and clip list) is open but same error.

                            PS how do I copy the error log file into this forum?

                            1. samuel henriques @samuel_henriques
                                2021-05-11 19:24:39.541Z2021-05-11 19:42:32.224Z

                                try this one, it won't open track list,

                                sf.ui.proTools.appActivateMainWindow()
                                
                                const trackName = "MUZIEK galm"
                                
                                
                                let visibleTracks = sf.ui.proTools.visibleTrackNames
                                
                                // If track is visible
                                if (visibleTracks.indexOf(trackName) >= 0) {
                                
                                  // Select Track
                                  sf.ui.proTools.trackGetByName({ name: trackName }).track.trackScrollToView()
                                  //  Hide Selected
                                  sf.ui.proTools.selectedTrack.popupButtons.first.popupMenuSelect({isRightClick:true, menuPath:["Hide"]})
                                
                                } else {
                                
                                  // If the track to show is selected, the command wont work so we need to deselect all tracks, just as safety
                                  sf.ui.proTools.trackDeselectAll()
                                  sf.ui.proTools.trackGetByName({ name: trackName, makeVisible: true }).track.trackSelect()
                                
                                }
                                
                                ReplySolution
                                1. samuel henriques @samuel_henriques
                                    2021-05-11 19:26:29.390Z

                                    to copy the log info

                                    click log file and look for the error message, at the end, don't post the complete log, it might have loads of information not related

                                    1. DDavid Heylen @David_Heylen5
                                        2021-05-11 19:35:54.671Z

                                        Thank you Samuel it works.

                                        Going to test some more so it opens the first plug in too.

                                        But thank you very much

                                        David

                                        1. samuel henriques @samuel_henriques
                                            2021-05-11 19:38:48.521Z

                                            Cool.

                                            just noticed a mistake on the comment
                                            // If track is not visible should be // If track is visible

                                        2. In reply toDavid_Heylen5:
                                          samuel henriques @samuel_henriques
                                            2021-05-11 19:27:20.614Z

                                            same error is this ?
                                            Could not evoke 'Hide Selected tracks' (MUZIEK galm copy line 12)
                                            Could not open track list popup menu
                                            popup menu was not found

                                            1. samuel henriques @samuel_henriques
                                                2021-05-11 19:38:03.854Z

                                                If the track list is open but the popup is covered, it won't work either.