Issue Writing Script Template
Hey all. I'm trying to utilize a script template to recall track presets for Headphone Sends. My primary script works just fine, but then I tried converting it to a template, where each new preset selects a different recall setting. In this example, when I create a new script preset, I enter into the String{} container, the following:
'Recall Track Presets', 'Avid', 'Headphones', 25-26' (or whatever numbers of the corresponding track preset
I just can't seem to get it to complete the command, using the presets. It always hangs up on Line 12.
Here is my template script:
const menuPath = event.props.menuPath
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.mainWindow.invalidate();
var originallySelectedTrackNames = sf.ui.proTools.selectedTrackNames;
function ensureFirstSelectedTrackIsVisible() {
var originallySelectedTrackNames = sf.ui.proTools.selectedTrackNames;
sf.ui.proTools.selectedTrack.trackScrollToView();
sf.ui.proTools.trackSelectByName({ names: originallySelectedTrackNames, deselectOthers: true });
}
function recallTrackPreset() {
sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({
isRightClick: true,
menuPath: []
});
}
function main() {
if (sf.ui.proTools.getMenuItem('Window', 'Mix').isMenuChecked) {
sf.ui.proTools.menuClick({
menuPath: ["Window", "Edit"],
targetValue: "Enable",
});
ensureFirstSelectedTrackIsVisible()
recallTrackPreset();
sf.ui.proTools.menuClick({
menuPath: ["Window", "Mix"],
targetValue: "Enable",
});
sf.ui.proTools.trackSelectByName({ names: originallySelectedTrackNames, deselectOthers: true });
}
else {
ensureFirstSelectedTrackIsVisible();
recallTrackPreset();
sf.ui.proTools.trackSelectByName({ names: originallySelectedTrackNames, deselectOthers: true });
}
}
main();
- Raphael Sepulveda @raphaelsepulveda2021-11-06 21:09:54.947Z
Hey Daniel,
Quickly going over your script, the problem seems to lie on the
popupMenuSelect()
function insiderecallTrackPreset()
. ThemenuPath
property ofpopupMenuSelect()
is set to an empty array.The solution is simple though! Just get rid of the empty array and the
menuPath
property will inherit the value of themenuPath
constant at the top of the script—which will yield the desired result. So basically, make therecallTrackPreset()
function look like this:function recallTrackPreset() { sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({ isRightClick: true, menuPath }); }
By the way, the following video will show you how to quote code here in the forum:
https://www.youtube.com/watch?v=FRLCp6Sf9AI- DDaniel Goodwin @Daniel_Goodwin
Thank you for script quote tip!
I tried as you said, and now Im getting the error: MenuPath or Menu Selector is required
Not sure what I'm doing wrong here. I'm so sorry, I'm such a novice wirth code matters
Christian Scheuer @chrscheuer2021-11-07 20:19:08.996Z
This indicates that nothing is passed in the menuPath property to the popupMenuSelect action. Make sure you're getting that from event.props and that the property has been filled out in your template.
It would be easier to help if you share screenshots of your template setup, the preset you're running, and the full template script.