No internet connection
  1. Home
  2. How to

Grid mode toggle

By Thomas Gloor @Thomas_Gloor
    2021-07-08 08:17:25.941Z

    As requested by @samuel_henriques here's a repost of my question about Grid Mode Toggle script


    I have a toggle command to flip between SLIP and ABS GRID mode but it fails when the grid is in REL GRID.

    var grid = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Edit Mode Cluster").first.buttons.whoseTitle.is("Absolute Grid mode").first;
    var relgrid = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Edit Mode Cluster").first.buttons.whoseTitle.is("Relative Grid mode").first;
    
    var slip = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Edit Mode Cluster").first.buttons.whoseTitle.is("EditModeSlip").first;
    
    if(grid.value.invalidate().value === "Selected") {
        slip.elementClick();
    } else {
        grid.elementClick()
    }
    

    Does someone have a variant of your EDIT TOOL TOGGLE for this? That would not fail but just stay in rel grid, or even better, switch to abs grid and move on?

    Best,

    T.

    • 3 replies
    1. samuel henriques @samuel_henriques
        2021-07-08 08:40:10.061Z

        Hey Thomas,
        thank you for that.

        Here's what I come up just now, let me know if it works.

        It should select slip when it's not selected, and if it is, select grid. And if grid is relative, change to Absolute.

        //Activate Pro Tools
        sf.ui.proTools.appActivate();
        
        
        // Get edit mode cluster btn elements
        const { shuffleModeButton, spotModeButton, slipModeButton, gridModeButton } = sf.ui.proTools.mainWindow.editModeCluster
        
        // If slip is selected
        if (slipModeButton.value.invalidate().value === "Selected") {
        
            // select grid
            gridModeButton.elementClick()
        
            // If grid is not absolute
            if (gridModeButton.title.invalidate().value != "Absolute Grid mode") {
        
                // Click grid btn to change
                gridModeButton.elementClick()
            }
        
            // Else if slip is not selected, select slip
        } else if (slipModeButton.value.invalidate().value != "Selected") {
        
            // Select slip
            slipModeButton.elementClick()
        
        }
        
        1. TThomas Gloor @Thomas_Gloor
            2021-07-08 09:53:10.383Z

            Hey @samuel_henriques

            Thank you so much!

            Am I right to think that if I just want to toggle between SLIP and the current Grid Mode, I should just remove this part?

                // If grid is not absolute
                if (gridModeButton.title.invalidate().value != "Absolute Grid mode") {
            
                    // Click grid btn to change
                    gridModeButton.elementClick()
                }
            
            1. samuel henriques @samuel_henriques
                2021-07-08 09:59:19.611Z

                Yes, that's correct.