No internet connection
  1. Home
  2. How to

How to toggle between smart tool (trim TCE) and smart tool (trim standard)

Here's 2 scripts to toggle the smart tool to Smart tool with Trim = Time Compression/Expansion - and to select smart tool with normal trim.

Smart tool with TCE:

sf.ui.proTools.appActivateMainWindow();

if (sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.title.invalidate().value.indexOf('Time Compression') < 0) {
    sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuSelect({ menuPath: ['TCE'], isRightClick: true });
}

sf.ui.proTools.toolsSelect({
    tool: 'Smart'
});


Smart tool with normal trim:

sf.ui.proTools.appActivateMainWindow();

if (sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.title.invalidate().value != "Trim tool") {
    sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuSelect({ menuPath: ['Standard'], isRightClick: true });
}

sf.ui.proTools.toolsSelect({
    tool: 'Smart'
});
Solved in post #2, click to view
  • 10 replies
  1. Solution in the original post

    ReplySolution
    1. J
      In reply tochrscheuer:
      Jon Shamieh @Jon_Shamieh
        2019-12-26 21:45:14.359Z

        Perhaps a silly question, but how do I set up a Macro to Toggle between these two?

        1. You can't set up a macro to do this since macros don't have if/else logic yet - it has to be a script. You can use Macros and Scripts interchangeably though. Is there a specific reason why you'd prefer this as a macro?

          1. Ah gotcha, you just meant a script that can toggle instead of manually selecting either.

            You could do that like this:

            sf.ui.proTools.appActivateMainWindow();
            
            if (sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.title.invalidate().value.indexOf('Time Compression') < 0) {
                sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuSelect({ menuPath: ['TCE'], isRightClick: true });
            } else {
                sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuSelect({ menuPath: ['Standard'], isRightClick: true });
            }
            
            sf.ui.proTools.toolsSelect({
                tool: 'Smart'
            });
            
            1. JJon Shamieh @Jon_Shamieh
                2019-12-26 22:12:02.290Z

                Yep, didn't need to be a macro, that did it – thank you!

                1. In reply tochrscheuer:
                  AAndrew Sherman @Andrew_Sherman
                    2021-09-06 14:27:14.112Z

                    Very handy script

              • In reply tochrscheuer:
                Dustin Harris @Dustin_Harris
                  2020-07-23 21:22:58.538Z

                  related, and building upon the flat menu items discussion with @chrscheuer and @Kitch here:

                  https://forum.soundflow.org/-2271/how-to-convert-a-flat-menu-item-into-an-array#post-2

                  I've made two scripts that allow the user to set the trim tool to standard or TCE and checks which state the button is currently in before changing it (saves a bit of time during selection).

                  Standard:

                  sf.ui.proTools.appActivateMainWindow();
                  let menuItems = sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuFetchAllItems({ isRightClick: true, }).menuItems;
                  let checkedMenuItem = String(menuItems.filter(m => m.element.isMenuChecked));
                  sf.ui.proTools.appActivateMainWindow();
                  if (checkedMenuItem !== "Standard"){
                  
                      sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuSelect({ menuPath: ['Standard'], isRightClick: true });
                  }
                  

                  TCE:

                  sf.ui.proTools.appActivateMainWindow();
                  let menuItems = sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuFetchAllItems({ isRightClick: true, }).menuItems;
                  let checkedMenuItem = String(menuItems.filter(m => m.element.isMenuChecked));
                  sf.ui.proTools.appActivateMainWindow();
                  if (checkedMenuItem !== "TCE"){
                  
                      sf.ui.proTools.mainWindow.cursorToolCluster.trimTool.popupMenuSelect({ menuPath: ['TCE'], isRightClick: true });
                  }
                  

                  Cheers!

                  1. Kitch Membery @Kitch2020-07-23 21:26:05.203Z

                    Nice one @Dustin_Harris!

                    1. In reply toDustin_Harris:
                      Daniel Perez @daniel_perez
                        2024-01-07 08:59:01.559Z

                        is this one improved with the help of the new pt scripting sdk?

                        1. Dustin Harris @Dustin_Harris
                            2024-01-13 00:51:10.462Z

                            Heyya Daniel, there is no SDK command yet for changing the selected tool (at least none I could find in the SDK documentation AVID provides) so for the time being, we'll have to make do with what we have :)

                            -D