No internet connection
  1. Home
  2. How to

Nudge not working inside of a function

By Chip Sloan @ChipSloan
    2021-03-24 00:23:30.827Z

    I have a script that works just as inteneded that is, until I put it into a function for do to all clips. As soon as it's in that function the nudge setting no longer works right. Any idea why that would happen?

    sf.ui.proTools.appActivateMainWindow();
    
    
    
    
    
    function makePopGroupEven() {
    
    
    
    
        sf.ui.proTools.menuClick({
            menuPath: ["Edit", "Copy"],
        });
    
    
        sf.keyboard.press({
            keys: "tab",
        });
    
        sf.keyboard.press({
            keys: "alt+tab",
        });
    
        sf.ui.proTools.nudgeSet({
            value: "00:00:01:00.00",
        });
    
        sf.keyboard.press({
            keys: "comma",
        });
        sf.keyboard.press({
            keys: "comma",
        });
    
    
        sf.ui.proTools.menuClick({
            menuPath: ["Edit", "Paste"],
        });
    
    
        sf.keyboard.press({
            keys: "shift+tab",
        });
    
        sf.ui.proTools.menuClick({
            menuPath: ["Clip", "Group"],
        });
    
    
    
        sf.ui.proTools.nudgeSet({
            value: "00:00:00:01.00",
        });
    
    
    
        sf.keyboard.press({
            keys: "tab3",
        });
    
        sf.keyboard.press({
            keys: "alt+tab",
        });
    
    
        sf.keyboard.press({
            keys: "cmd+shift+numpad plus",
        });
    
    
        sf.ui.proTools.waitForNoModals();
    
    
        sf.keyboard.press({
            keys: "ctrl+alt+shift+3",
        });
    
        sf.ui.proTools.waitForNoModals();
    
        sf.keyboard.press({
            keys: "shift+tab",
        });
        sf.ui.proTools.menuClick({
            menuPath: ["Clip", "Group"],
        });
    
    
    
    }
    
    sf.ui.proTools.clipDoForEachSelectedClip({
        action: makePopGroupEven
    });
    
    
    
    
    
    

    Any thoughts? Thanks.

    • 4 replies
    1. Dustin Harris @Dustin_Harris
        2021-03-24 01:07:50.009Z

        Is the keypress ‘tab3’ intentional?

        1. In reply toChipSloan:
          Chip Sloan @ChipSloan
            2021-03-24 01:12:19.372Z

            Right, I already fixed that on my end but that is not the issue. If I take that whole thing out of the function and test it I get perfect results. Once in the function I watch it and can see that the nudge command never sets the value to timecode, only a string of numbers with no punctuation.

            1. Hi Chip,

              This is because the clipDoForEachSelectedClip action works in Samples.
              If you need to work in timecode inside the callback function, you'll need to switch to Timecode in the beginning of your function, and back to Samples in the end of the function.

              1. Chip Sloan @ChipSloan
                  2021-03-24 17:28:59.955Z

                  Great! Thanks! I'll try that.

                  C