No internet connection
  1. Home
  2. How to
  3. Pro Tools

Toggle Folder Open/Close Not Working As Expected...

By Jon Lipman @Jon_Lipman
    2024-12-18 02:17:43.220Z

    Hello,

    I'm having intermittent issues with the Toggle Folder Track Open/Close action. It works only occasionally and otherwise gives me this error.

    Logging error in action (01) FolderTrackSetOpenAction: Could not click Open/Close Folder

    17.12.2024 18:12:24.15 [Backend]: Logging unknown error in action (02) RunCommandAction: Toggle Folder Track Open/Close: Line 5

    17.12.2024 18:12:24.15 [Backend]: JavaScript error with InnerException: Could not click Open/Close Folder (Toggle Folder Track Open/Close: Line 5)
    !! Command Error: TOGGLE FX [user:ckz4kpwnr0005t2101rnyu5v1:cm4j8hwav0007nl1083svkcv4]:
    Error: Toggle Folder Track Open/Close: Line 5
    (TOGGLE FX line 4)

    Solved in post #18, click to view
    • 17 replies
    1. S
      SoundFlow Bot @soundflowbot
        2024-12-18 02:17:47.167Z

        Thanks for contacting SoundFlow support.

        Please note, that the best way to get help with a script, macro or other content installed from the Store or content that you've made yourself, is to select the script/macro, then click the red Need help button, and then click "Get help with this script or macro".
        By using this method, we will get access to more information and so should be able to help you quicker.
        You can read more about how this works here: bit.ly/sfscripthelp

        If you're seeing an error that isn't related to scripts or macros, and you think this is a bug in SoundFlow, please file a Help/Issue bug report.
        You can see how to do this by going to bit.ly/sfhelpissue

        1. J
          In reply toJon_Lipman:
          Jon Lipman @Jon_Lipman
            2024-12-18 02:42:23.841Z

            This seems to have to do with track size...if size is micro the script seems not to be able to virtually click on where it needs to. There's no issue with tracks set to large.

            1. In reply toJon_Lipman:
              Kitch Membery @Kitch2024-12-18 03:42:50.953Z

              Hi @John_Lipman,

              Here is a way to toggle track folders open and closed using the Pro Tools API, which should work with all track heights.

              sf.app.proTools.invalidate();
              
              const selectedFolderTracks = sf.app.proTools.tracks.allItems.filter(track => {
                  return track.isSelected && track.type.endsWith("Folder");
              });
              
              selectedFolderTracks.forEach(track => {
                  const trackName = track.name;
                  const isOpen = track.isOpen
              
                  sf.app.proTools.setTrackOpenState({
                      trackNames: [trackName],
                      enabled: !isOpen
                  });
              });
              

              I hope that helps.

              1. C@ChristiaanUnck
                  2025-01-08 08:24:18.343Z

                  Great script, thanks! Is it also possible to make this script open and close all folders at once? So not only the selected ones? Thanks! Christiaan.

                  1. Kitch Membery @Kitch2025-01-08 20:21:02.707Z

                    Hi @ChristiaanUnck,
                    Yes indeed! Try this!

                    sf.app.proTools.invalidate();
                    
                    const folderTracks = sf.app.proTools.tracks.allItems.filter(track => {
                        return track.type.endsWith("Folder");
                    });
                    
                    const areAnyFoldersOpen = folderTracks.filter(track => track.isOpen).length > 0;
                    
                    const openFolder = !areAnyFoldersOpen ? true : false;
                    
                    folderTracks.forEach(track => {
                        const trackName = track.name;
                    
                        sf.app.proTools.setTrackOpenState({
                            trackNames: [trackName],
                            enabled: openFolder
                        });
                    });
                    
                    1. In reply toChristiaanUnck:
                      Kitch Membery @Kitch2025-01-08 20:23:20.528Z2025-01-13 22:54:40.177Z

                      Actually this is better...

                      sf.app.proTools.tracks.invalidate();
                      
                      const folderTracks = sf.app.proTools.tracks.allItems.filter(track => {
                          return track.type.endsWith("Folder");
                      });
                      
                      const folderTrackNames = folderTracks.map(track => track.name);
                      
                      const areAnyFoldersOpen = folderTracks.filter(track => track.isOpen).length > 0;
                      
                      const openFolders = !areAnyFoldersOpen ? true : false;
                      
                      sf.app.proTools.setTrackOpenState({
                          trackNames: folderTrackNames,
                          enabled: openFolders,
                      });
                      
                      

                      [UPDATED]

                      1. JJon Lipman @Jon_Lipman
                          2025-01-13 22:01:48.813Z

                          Will test and report thanks for the code!

                          1. In reply toKitch:

                            This is good, but please keep in mind it's generally best to always only invalidate on the level of the node hierarchy that you need. In this case, you need to invalidate the tracks cache, since you're operating on tracks, but there's no need to clear caches of say memory locations etc.

                            So, the first line:

                            sf.app.proTools.invalidate();
                            

                            Would be more performant like so:

                            sf.app.proTools.tracks.invalidate();
                            

                            Since other scripts that would rely on other parts of the cache would not necessarily have to refresh it.

                            1. Kitch Membery @Kitch2025-01-13 22:53:31.190Z

                              Absolutely. Whoops that was a mistake. :-)

                        • In reply toKitch:
                          JJon Lipman @Jon_Lipman
                            2025-01-14 00:21:48.234Z

                            I'm not able to get this fully working. It opens or closes whatever folder I'm currently on but won't target the track. In this example - I'm trying to open/close the folder "WHFX" Is this setup correctly?

                            
                            sf.app.proTools.invalidate();
                            
                            const selectedFolderTracks = sf.app.proTools.tracks.allItems.filter(track => {
                                return track.isSelected && track.type.endsWith("Folder");
                            });
                            
                            selectedFolderTracks.forEach(track => {
                                const WHFX = track.name;
                                const isOpen = track.isOpen
                            
                                sf.app.proTools.setTrackOpenState({
                                    trackNames: [WHFX],
                                    enabled: !isOpen
                                });
                            });
                            
                            1. Kitch Membery @Kitch2025-01-14 02:05:33.267Z

                              Hi @Jon_Lipman,

                              If you're trying to toggle open a single folder named "WHFX", you'd do something like this...

                              const targetFolderName = "WHFX";
                              
                              sf.app.proTools.tracks.invalidate();
                              
                              const folderTrack = sf.app.proTools.tracks.allItems.find(track =>
                                  track.name === targetFolderName && track.type.endsWith("Folder")
                              );
                              
                              if (folderTrack) {
                                  const isTargetFolderOpen = folderTrack.isOpen;
                              
                                  sf.app.proTools.setTrackOpenState({
                                      trackNames: [targetFolderName],
                                      enabled: !isTargetFolderOpen
                                  });
                              } else {
                                  throw `No folder named ${targetFolderName} was found.`
                              }
                              
                              1. JJon Lipman @Jon_Lipman
                                  2025-01-14 02:20:35.031Z

                                  Works great thank you!...random but when I go to write the script it immediately zips me back to the deck arrange screen. It seems like I'm fighting Soundflow to keep the script window open. Any reason this could be?

                                  1. Kitch Membery @Kitch2025-01-14 02:24:49.945Z

                                    That seems very strange, would you mind if I took a look at your account?

                                    1. JJon Lipman @Jon_Lipman
                                        2025-01-14 02:27:46.609Z

                                        Sure you can take a look - how can I give you access? Here's my deck designer screenshot. Thanks much.

                                      • In reply toJon_Lipman:
                                        Kitch Membery @Kitch2025-01-14 02:25:44.534Z

                                        Actually, can I get you to take a screenshot of the Deck designer page?

                                        1. In reply toJon_Lipman:
                                          Kitch Membery @Kitch2025-01-14 02:38:42.732Z

                                          Thanks for providing that screenshot.

                                          Right now you have the command filter set to "Decks" rather than "All" in the top left of the SoundFlow interface.

                                          Switching it to "All" should resolve the issue.

                                          Reply1 LikeSolution
                                  2. J
                                    In reply toJon_Lipman:
                                    Jon Lipman @Jon_Lipman
                                      2024-12-19 00:10:41.067Z

                                      Wonderful I’ll try this now thanks!