No internet connection
  1. Home
  2. How to

Show Hide Track TOGGLE

By Dav3 @D_av_3
    2021-03-25 10:53:28.635Z2021-03-25 19:09:39.439Z

    Hello everybody.
    I was trying to create a simple script to show some groups of tracks. For example, all voiceover tracks have the prefix "☆☆".
    So I created a macro with this code. (By the way ... how do you share the box with the code?)

    sf.ui.proTools.trackShowByName ({
         names: ["☆☆"],
         search: true,
    });
    

    It works.
    However, it would be handy to have this function with toggle, but I didn't understand how to do it ..
    do you have any advice?

    Solved in post #5, click to view
    • 9 replies
    1. samuel henriques @samuel_henriques
        2021-03-25 17:02:11.402Z

        Hey @Davide_Docente,

        try this:

        sf.ui.proTools.appActivateMainWindow();
        
        const trackMatch = sf.ui.proTools.trackNames.filter(x => x.match('☆☆'))
        
        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 })
        }
        
        1. Dav3 @D_av_3
            2021-03-26 09:43:50.554Z

            It works!!
            Great!!!
            thank you!!

            Reply1 LikeSolution
            1. This is great! Turned it into a template and already have 3 presets I'm using for it. It's nice how it's slighlty diffrent function then memory locations show/hide because it can just add/subtract from current track you're looking at.

              1. GGaston Ibarroule @Gaston_Ibarroule
                  2022-03-02 10:16:23.715Z

                  Hey Samuel. Excuse my ignorance. But how would you include multiple tracks to toggle? I think it's a matter of syntax why I can't add more in the third line:

                  const trackMatch = sf.ui.proTools.trackNames.filter(x => x.match('PFX_M1', 'PFX_M2'))
                  

                  It would be amazing if someone could send me in the direction of how to lear to ennumerate within this constants.

                  Thanks!

                  1. samuel henriques @samuel_henriques
                      2022-03-02 10:50:39.254Z2022-03-02 11:13:17.521Z

                      Hello Gaston,

                      Try this,

                      sf.ui.proTools.invalidate();
                      
                      const namesToFind = ['PFX_M1', 'PFX_M2']
                      
                      const foundNames = sf.ui.proTools.trackNames.filter(name => namesToFind.indexOf(name) > -1)
                      
                      globalState.showtoggle = !globalState.showtoggle
                      
                      if (globalState.showtoggle) {
                          //  Hide Tracks
                          sf.ui.proTools.trackSelectByName({ names: foundNames })
                          sf.ui.proTools.trackVisibilityHideSelected()
                      
                      } else {
                          //  Show Tracks
                          sf.ui.proTools.trackShowByName({ names: foundNames })
                      }
                      
                      1. GGaston Ibarroule @Gaston_Ibarroule
                          2022-03-02 10:55:31.533Z

                          Amazing! Works like a charm. I'll try to replicate the constant in other scripts. Thank you @smanuel_henriques !!

                          1. samuel henriques @samuel_henriques
                              2022-03-02 11:14:45.624Z

                              Cool,
                              I just added .invalidate(), it's important in case session track name list changes.

                      2. In reply toD_av_3:
                        Kitch Membery @Kitch2021-03-25 19:09:19.253Z

                        Hi @Davide_Docente,

                        Please check this tutorial for how to quote code in the SoundFlow forum, so that it displays in a readable format:

                        1. Dav3 @D_av_3
                            2021-03-25 20:39:50.066Z

                            THX!!