Can someone help me modify this script to copy clips to specific tracks
Title
Can someone help me modify this script to copy clips to specific tracks
What do you expect to happen when you run the script/macro?
Copy clip, clip group it, name group, mute group, paste to specific track
Are you seeing an error?
What happens when you run this script?
The script works as is but I can't seem to figure out how to clip group, mute the group and rename it to a specific name after copying the clip
How were you running this script?
I used a Stream Deck button
How important is this issue to you?
5
Details
{ "inputExpected": "Copy clip, clip group it, name group, mute group, paste to specific track", "inputIsError": false, "inputWhatHappens": "The script works as is but I can't seem to figure out how to clip group, mute the group and rename it to a specific name after copying the clip", "inputHowRun": { "key": "-MpfwmPg-2Sb-HxHQAff", "title": "I used a Stream Deck button" }, "inputImportance": 5, "inputTitle": "Can someone help me modify this script to copy clips to specific tracks" }
Source
const trackNames = event.props.trackNames;
function copyButRememberSelection() {
sf.ui.proTools.mainCounterDoWithValue({
targetValue: 'Samples',
action: () => {
//Get original selection
var originalSelection = sf.ui.proTools.selectionGetInSamples();
var editCopy = sf.ui.proTools.getMenuItem('Edit', 'Copy');
if (!editCopy.isEnabled) throw 'No clip selected';
editCopy.elementClick({}, 'Could not copy clip');
sf.ui.proTools.selectionSetInSamples({
selectionStart: originalSelection.selectionStart,
selectionEnd: originalSelection.selectionEnd,
});
}
});
}
function selectionOverlapsWithExistingClip() {
return sf.ui.proTools.getMenuItem("Edit", "Trim Clip", "To Selection").exists;
}
function moveToTracks(trackNames) {
var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
copyButRememberSelection();
var success = false;
for (var i = 0; i < trackNames.length; i++) {
var trackName = trackNames[i];
sf.ui.proTools.trackSelectByName({
names: [trackName],
deselectOthers: true,
});
//Update menu
sf.keyboard.press({ keys: 'cmd+shift+numpad plus,cmd+shift+numpad minus' });
if (selectionOverlapsWithExistingClip())
continue;
var editPaste = sf.ui.proTools.getMenuItem('Edit', 'Paste');
if (!editPaste.isEnabled) throw 'Cannot paste here';
editPaste.elementClick({}, 'Could not paste clip');
success = true;
break;
}
sf.ui.proTools.trackSelectByName({
names: [originalTrackName],
deselectOthers: true,
});
if (!success) {
sf.ui.proTools.getMenuItem('Edit', 'Undo Cut').elementClick();
}
}
function main() {
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.invalidate();
//Get selected tracks
const originalTracks = sf.ui.proTools.selectedTrackNames;
//Do for each track.
sf.ui.proTools.selectedTracks.trackHeaders.slice().map(track => {
//Select track
track.trackSelect();
//Scroll track into View
track.trackScrollToView();
moveToTracks(trackNames);
});
//Restore previously selected tracks
sf.ui.proTools.trackSelectByName({ names: originalTracks });
}
main();
Links
User UID: MwqrVLXkfRPbLC92MshYzEMJClR2
Feedback Key: sffeedback:MwqrVLXkfRPbLC92MshYzEMJClR2:-OBxHGDsFhUnF00Iprdp
Feedback ZIP: WjXhtWYuuB/lpyy1bRVT7WLYEY5RBH6SgxkS2WXJ8YWrEMcXIbULaGzN/Tv5W7QIbjExB+myZWD6fAMzR4t7qe/Kw1ofR88FGX3xcnWqmOoCEVy/TDRfKupe6+BCqXaJBNU37LNMCReKrieXlWaxAkzW4yzHcUyhmNPFpqU1Gl848pp51UeA1DojV/d0dgtPdDpe33B48BceXdUnOIGJAksbMRbHKF9pCQ8O3Eaf2WjmyuhE2vU/Uf1QMzBriHN9ECfRmaReAevRo5GEXc9q9Xumt6DlhkjFJuaqi9EJy+WQpDh0whC2bSVo9i1O0ZUqWr8wnv6EBGL+XnNk1x/L4DXV4/ziwqWFI2BOqY9wDKk=