No internet connection
  1. Home
  2. How to

Ensure Absolute Grid and Set Grid value

By Alexandre Hirlinger @Alexandre_Hirlinger
    2022-03-20 22:01:36.739Z

    Hello all! I have a workflow in logic that I'd like to emulate in protools. I have one keystroke that ensures that I am in logic's equivalent to "grid" mode and then sets the grid value to one bar. I have a script that I pulled from the forums that is supposed to do just that, but sometimes it doesn't work and it enables relative grid mode. Is there anyway to fix this?

    var gridBtn = sf.ui.proTools.mainWindow.editModeCluster.gridModeButton.invalidate();
    var isAbsolute = gridBtn.title.invalidate().value.indexOf("Absolute") === 0;
    var isSelected = ![
        sf.ui.proTools.mainWindow.editModeCluster.slipModeButton,
        sf.ui.proTools.mainWindow.editModeCluster.shuffleModeButton,
        sf.ui.proTools.mainWindow.editModeCluster.spotModeButton,
    ].some(btn => btn.value.invalidate().value === 'Selected');
    
    if (!isSelected) gridBtn.elementClick();
    if (!isAbsolute) { gridBtn.elementClick(); }
    
    sf.ui.proTools.gridSet({
        gridValueName: "1 bar",
    });
    

    Thanks!

    Solved in post #2, click to view
    • 2 replies
    1. Chris Shaw @Chris_Shaw2022-03-21 18:36:38.989Z2022-03-22 17:16:38.792Z

      It seems to work fine on my system. I did notice that the script doesn't check if the Edit window grid is set to Bars|Beats so I added a couple of lines to ensure that it is. That might be why it fails for you.
      I also added comments for the whole script.

      
      //Define grid mode button
      var gridBtn = sf.ui.proTools.mainWindow.editModeCluster.gridModeButton.invalidate();
      
      //Get state of Grid mode button (is it set to aabsolute?)
      var isAbsolute = gridBtn.title.invalidate().value.indexOf("Absolute") === 0;
      
      // Check if grid mode is selected (by checking if any other mode is checked) and select it if it isn't
      var isSelected = ![
          sf.ui.proTools.mainWindow.editModeCluster.slipModeButton,
          sf.ui.proTools.mainWindow.editModeCluster.shuffleModeButton,
          sf.ui.proTools.mainWindow.editModeCluster.spotModeButton,
      ].some(btn => btn.value.invalidate().value === 'Selected');
      
      if (!isSelected) gridBtn.elementClick();
      
      // If Absolute Grid mode is not selected click grid mode button again to switch it from Relative mode
      if (!isAbsolute) { gridBtn.elementClick(); }
      
      // Make sure Edit window grid is set to Bars|Beats
      sf.ui.proTools.gridSet({
          gridValueName: "Bars|Beats",
      });
      
      //Set edit grid to 1 bar
      sf.ui.proTools.gridSet({
          gridValueName: "1 bar",
      });
      
      Reply1 LikeSolution
      1. Thanks so much, @Chris_Shaw! I don't know why the old version was sporatically not working, but this appears to be stable. I'll let you know if I run into any hiccups. I also made a second script by taking the last few lines of code and that script will become my new F4 key (I rarely use relative grid mode, so I always want F4 to take me to absolute grid). Thanks so much for your help!