Then 2nd if else line's 26-31 are not working... I can't figure out why. The IF works but the ELSE does not...
Following script does as follows.
Make a selection of any number of tracks, hold command and press button to set globalState remembering the selected tracks and copy the audio in the selection. This way I can grab a SFX from anywhere in my show and instead of worrying about what tracks it was spread across simply navigate to where I want and press paste. All was well and working great.
I decided to get fancier with it in that if I highlighted a selection it would instead 'paste special' 'repeat to fill.' which works. But if it's not present the 'regular paste' else statment is not working... what am I dong wrong?
function copy() {
sf.ui.proTools.menuClick({ menuPath: ["Edit", "Copy"],});
}
function paste() {
sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Paste'] });
}
function pasteToFill() {
sf.ui.proTools.menuClick({ menuPath: ["Edit", "Paste Special", "Repeat to Fill Selection"] });
}
sf.ui.proTools.mainWindow.invalidate();
const repeatEnabled = sf.ui.proTools.getMenuItem("Edit", "Paste Special", "Repeat to Fill Selection").exists
if (event.keyboardState.hasCommand) {
/// Get Selected track names to variable
globalState.selectedTracks = sf.ui.proTools.selectedTrackNames
copy();
} else {
/// Re Select Tracks
sf.ui.proTools.trackSelectByName({ names: globalState.selectedTracks })
if (repeatEnabled) {
pasteToFill();
} else {
log('why no paste')
paste();
}
}
I also built it this way just to take out the nested ELSE to see if that'd help but also no dice.
function copy() {
sf.ui.proTools.menuClick({ menuPath: ["Edit", "Copy"], });
}
function paste() {
sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Paste'] });
}
function pasteToFill() {
sf.ui.proTools.menuClick({ menuPath: ["Edit", "Paste Special", "Repeat to Fill Selection"] });
}
sf.ui.proTools.mainWindow.invalidate();
const repeatEnabled = sf.ui.proTools.getMenuItem("Edit", "Paste Special", "Repeat to Fill Selection").exists
const modifierState = event.keyboardState.asString
switch (modifierState) {
case "cmd":
/// Get Selected track names to variable
globalState.selectedTracks = sf.ui.proTools.selectedTrackNames
copy();
break
case "":
/// Re Select Tracks
sf.ui.proTools.trackSelectByName({ names: globalState.selectedTracks })
if (repeatEnabled) {
pasteToFill();
} else {
log('why no paste')
paste();
}
break
};
What Obvious thing am I doing wrong?
- Nathan Salefski @nathansalefski
@Kitch relayed this message to me and it has saved me so much time in troubleshooting. How to use looseMatch in Popup Menu #post-14. Using this simple script I was able to determine the menu item exists regardless if you can select it or not:
Using this, I was able to determine if "Repeat to Fill Selection" was a valid selection option:const repeatEnabled = sf.ui.proTools.getMenuItem( "Edit", "Paste Special", "Repeat to Fill Selection").exists if (repeatEnabled) { log('yes') } else { log('no') }
const repeatEnabled = sf.ui.proTools.getMenuItem( "Edit", "Paste Special", "Repeat to Fill Selection").isEnabled if (repeatEnabled) { log('yes') } else { log('no') }
Simply replace the
.exists
with.isEnabled
in Line 15- OOwen Granich-Young @Owen_Granich_Young
I KNEW it was something dumb easy.
Thanks boss.Nathan Salefski @nathansalefski
I cannot tell you how many times I've spent days looking for a simple mistake lol