No internet connection
  1. Home
  2. How to

Duplicate playlist of selected track

By Andrew Scheps @Andrew_Scheps
    2020-02-15 18:08:39.280Z

    Duplicating the playlist of a selected track only works if that track is showing on the screen. If it's scrolled off the top or bottom there is an error. Any thoughts?

    sf.ui.proTools.selectedTrack.popupButtons.whoseTitle.is('Playlist selector').first.popupMenuSelect({
        menuPath: ["Duplicate..."],
    });
    
    Solved in post #2, click to view
    • 15 replies
    1. Hi Andrew

      You can preface your script with this code to make sure the selected track is in view.

      sf.ui.proTools.selectedTrack.trackScrollToView();
      

      The reason why it needs to be in view is that the login for opening popup menus requires the popup button to be visible.
      Generally speaking SoundFlow first uses UI Automation (which doesn't require elements to be visible), but then in cases where it can't use UI Automation due to limitations in Pro Tools, it falls back to keyboard and mouse simulation techniques (still enhanced by UI Automation though), and in those cases the elements that we simulate mouse clicks on need to be visible on screen.

      ReplySolution
      1. Andrew Scheps @Andrew_Scheps
          2020-02-15 19:58:48.674Z

          Thanks Christian, do you ever sleep????? I've made some absolutely gigantic progress in automating all of the boring parts of process today. If we can get Avid to fix the menu issue I'll be all set!

          1. I think the only way to fix the "Search menu" issue is if we could reset to default with a code, without the need to close Pro Tools and open it again.

        • A
          In reply toAndrew_Scheps:
          Andrew Downes @Andrew_Downes
            2020-02-20 22:24:07.676Z

            Is there a way to apply this to a selection of tracks? It works perfectly if its just 1 track but if there is more than 1 and the first selected is out of view, it will only select that track.
            I should add that I have applied this piece of script to go before a 'select next plugin slot' and a 'select next insert slot'
            Thanks

            1. Try adding a sf.ui.proTools.selectedTrack.trackScrollToView(); action before calling the above.

              1. AAndrew Downes @Andrew_Downes
                  2020-02-20 23:42:34.495Z

                  This the code I added in the first place. When I enact it it scrolls to the first selected track and then de-selects the the others.

                  1. Ah yea that makes sense - try this:

                    
                    function ensureFirstSelectedTrackIsVisible() {
                        var originallySelectedTrackNames = sf.ui.proTools.selectedTrackNames;
                        sf.ui.proTools.selectedTrack.trackScrollToView();
                        sf.ui.proTools.trackSelectByName({ names: originallySelectedTrackNames, deselectOthers: true });
                    }
                    
                    ensureFirstSelectedTrackIsVisible();
                    
                    sf.ui.proTools.selectedTrack.popupButtons.whoseTitle.is('Playlist selector').first.popupMenuSelect({
                        menuPath: ["Duplicate..."],
                    });
                    
                    1. AAndrew Downes @Andrew_Downes
                        2020-02-25 23:32:42.607Z

                        Hi Christian

                        Thanks, this works great except if the first track in the session is out of sight, then it deselects all the tracks you wanted and selects the next one. e.g select tracks 1, 2, 3, 4 and 5 with 1 being off the screen ends up with track 6 selected.

                        1. With this script exactly like I posted it there? That's strange, sounds like a bug in trackSelectByName then.

                        2. In reply tochrscheuer:
                          Russ Donohue @Russ_Donohue
                            2022-01-08 22:31:59.925Z

                            Hii Christian,

                            With this script, it works the first time a session is opened, but then I'm getting "No track selected (in Track List View)".

                            It suggests link track and edit selection, but isn't working either way.

                            Sorry if I'm missing something obvious!

                            1. DDamon Castillo @Damon_Castillo
                                2022-01-31 21:28:40.144Z

                                I get the same error whether it's New Playlist or Duplicate Playlist. Works the first time but says "Reference Error: Reply is not defined". After that, it doesn't work, saying "No track selected (in Track List View)", although the track is selected and I have Link Timeline and Edit Selection engaged. Would LOVE to get this to work!

                                1. DDamon Castillo @Damon_Castillo
                                    2022-02-08 17:35:04.924Z

                                    Any fixes yet?

                                    1. Hi Damon,

                                      It might be better to open a new thread for this to get more eyes on it. Threads marked as solved don't get the same attention.

                                      One thing you should consider would be to invalidate SF's track cache, as duplicating tracks might cause issues with it.

                                      Insert this at the top of your script

                                      sf.ui.proTools.mainWindow.invalidate();
                                      
                                      1. Russ Donohue @Russ_Donohue
                                          2022-02-10 02:47:38.339Z

                                          This seems to have worked!!! Thank you Christian!! This is awesome... Works perfectly

                                          1. In reply tochrscheuer:
                                            DDamon Castillo @Damon_Castillo
                                              2022-02-10 17:48:22.527Z

                                              Thank you for the tip on opening new thread!
                                              Yes, this works for me too for both New Playlist and Duplicate Playlist. I still get an error message, but it works!
                                              Thank you Christian!
                                              Damon