Is there a way to let SF see if vca tracks are assigned to anything?
I want to make a script that selects all vca faders in a session that are not assigned to any group and then delete them. I can make a script that does it, but I can't think of a way to only select unassigned vca's. I guess I need SF to pick up the output stage of the vca’s or something like that.
- Nathan Salefski @nathansalefski
Here you go:
function selectTracksByType({ trackType }) { const names = sf.ui.proTools.visibleTrackHeaders.filter(track => { return track.title.value.trim().endsWith(trackType) }); sf.ui.proTools.trackSelectByName({ names: names.map(t => t.normalizedTrackName), deselectOthers: true, }); } function checkVcaGroupAssignment(track, tracksToDelete) { sf.ui.proTools.trackSelectByName({ names: [track] }); sf.ui.proTools.selectedTrack.trackScrollToView(); let groupAssignmentSelector = sf.ui.proTools.selectedTrack.invalidate().groups.whoseTitle.is("VCA IO").first.buttons.first; let groupName = groupAssignmentSelector.value.invalidate().value; if (groupName === 'no group') { tracksToDelete.push(track); } } function getTracksToDelete(track) { let tracksToDelete = [] track.forEach(track => { checkVcaGroupAssignment(track, tracksToDelete) }); return tracksToDelete; } function main() { sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); selectTracksByType({ trackType: 'VCA Track' }); let tracksToDelete = getTracksToDelete(sf.ui.proTools.selectedTrackNames); log(tracksToDelete); sf.ui.proTools.trackSelectByName({ names: tracksToDelete, deselectOthers: true, }); sf.ui.proTools.menuClick({ menuPath: ['Track', 'Delete'] }); } main();
Nathan Salefski @nathansalefski
@Kitch originally I tried to do it like this, mapping a function. Since I was using a conditional statement,
if (groupName === 'no group') { return track; }
, it was returning a'null'
when it didn't match those conditions. Therefore thesf.ui.proTools.trackSelectByName();
in Line 33 wasn't working. How could I have gotten rid of that'null'
?function selectTracksByType({ trackType }) { const names = sf.ui.proTools.visibleTrackHeaders.filter(track => { return track.title.value.trim().endsWith(trackType) }); sf.ui.proTools.trackSelectByName({ names: names.map(t => t.normalizedTrackName), deselectOthers: true, }); } function getTracksToDelete(track) { sf.ui.proTools.trackSelectByName({ names: [track] }); sf.ui.proTools.selectedTrack.trackScrollToView(); let groupAssignmentSelector = sf.ui.proTools.selectedTrack.invalidate().groups.whoseTitle.is("VCA IO").first.buttons.first; let groupName = groupAssignmentSelector.value.invalidate().value; if (groupName === 'no group') { return track; } } function main() { sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); selectTracksByType({ trackType: 'VCA Track' }); let tracksToDelete = sf.ui.proTools.selectedTrackNames.map(track => getTracksToDelete(track)); sf.ui.proTools.trackSelectByName({ names: tracksToDelete, deselectOthers: true, }); sf.ui.proTools.menuClick({ menuPath: ['Track', 'Delete'] }); } main();
Kitch Membery @Kitch2024-02-13 08:58:59.254Z
Try this script instead.
function deleteUnassignedVcaTracks() { sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); const trackNames = sf.ui.proTools.visibleTrackNames; let unusedVcaTrackNames = []; trackNames.forEach(name => { const track = sf.ui.proTools.trackGetByName({ name }).track; if (track.title.value.trim().endsWith("VCA Track")) { const vcaIoGroup = track.groups.whoseTitle.is("VCA IO").first const groupAssignmentSelector = vcaIoGroup.buttons.whoseTitle.startsWith("Group Assignment selector").first; if (groupAssignmentSelector.exists && groupAssignmentSelector.value.invalidate().value === "no group") { // If the Group Assignment selector's value is "no group" add the track name to the unusedVcaTrackNames array. unusedVcaTrackNames.push(name); } } }); // Select the Tracks sf.ui.proTools.trackSelectByName({ names: unusedVcaTrackNames, deselectOthers: true, }); // Delete sf.ui.proTools.menuClick({ menuPath: ['Track', 'Delete'] }); } deleteUnassignedVcaTracks();
Let me know how it goes.
- Mmikkeljm @mikkeljm
Works like a charm. Just needed to validate main window before Delete. Perfect thanks a lot.
- In reply toKitch⬆:
Nathan Salefski @nathansalefski
That's cool, I didn't know you wouldn't need to scroll to each track in order to determine the value of the
groupAssignmentSelector
. Is that true of other track properties?Kitch Membery @Kitch2024-02-13 19:07:31.577Z
Exactly...
sf.ui.proTools.trackGetByName
for the win!- In reply tonathansalefski⬆:
Kitch Membery @Kitch2024-02-13 19:10:39.715Z
Yes, it's true for other track properties.
The
sf.ui.proTools.trackGetByName
method allows you to get the track without selecting it. It returns the full track header as seen in line 10 of my script.- Mmikkeljm @mikkeljm
I guess this is kind of related to your script above @Kitch
I have this script that routes, and puts a track in a folder for programmed kick drums. It creates a group and add an already created vca fader to the group. I also have a folder for programmed snare drum that does the same, but I need SF to read the state of the vca io so it doesn't try and add the vca to the group once again. I can't figure out how to write that "if else" statement.- In reply tomikkeljm⬆:
Nathan Salefski @nathansalefski
I'd suggest marking this issue solved and opening up a new thread for separate scripts. It's easier for them to track down issues and easier for other users to see solutions to similar problems. 👍
- In reply tomikkeljm⬆:Mmikkeljm @mikkeljm
So here's the script I use as an example
let targetOutputName = "Prg Kick (Stereo)"; sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); sf.ui.proTools.selectedTrack.trackOutputSelect({ outputSelector: menuItems => menuItems.filter(mi => mi.path[mi.path.length - 1] === targetOutputName)[0], selectForAllSelectedTracks: true, }); sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({ isRightClick: true, menuPath: ['Move to...', ' -Prg Kick'], }); // Get originally selected tracks and first orig selected track const origSelectedTracks = sf.ui.proTools.selectedTrackNames; const firstSelectedTrack = origSelectedTracks[0]; /** * @param {string} trackName * @param {string[]} selectedTracks */ function scrollToTrackNamed(trackName, selectedTracks) { // Open scroll to track dialog and enter track name sf.ui.proTools.menuClick({ menuPath: ['Track', 'Scroll to Track...'] }); var confirmationDialogWin = sf.ui.proTools.confirmationDialog; confirmationDialogWin.elementWaitFor(); confirmationDialogWin.textFields.first.elementSetTextFieldWithAreaValue({ value: trackName }); confirmationDialogWin.buttons.whoseTitle.is('OK').first.elementClick(); confirmationDialogWin.elementWaitFor({ waitType: 'Disappear' }); //Re-select originally selected tracks sf.ui.proTools.trackSelectByName({ names: origSelectedTracks }) }; sf.wait({ intervalMs: 500, }); //Calling command "Create and Add To Groups" from package "undefined" (installed from user/pkg/version "sp8S3ewi4RhTvy8g6wz5cBzljUJ2/ckf4cskt4000ky4101o721bfs/clcgra10y0004ms10akaklrj9") sf.soundflow.runCommand({ commandId: 'user:ckzfaw4m90001j710060jpvnm:ckf4cv3ei000oy410dgixx1tu', props: { groupName: "PRG", groupNumber: "1", letter: "d", disableGroupAfterCreation: true, createVCA: false, groupAction: "create", } }); sf.wait({ intervalMs: 500, }); sf.ui.proTools.colorsSelect({ colorNumber: 01, }); sf.ui.proTools.trackSelectByName({ names: ["Prg"], }); sf.wait({ intervalMs: 500, }); sf.ui.proTools.selectedTrack.groups.whoseTitle.is("VCA IO").first.buttons.first.popupMenuSelect({ menuPath: ["d - PRG"], });
Kitch Membery @Kitch2024-02-14 07:24:06.038Z
Answered here...