Hi,
Looking to be able to remove a track from 1 group. but leave it to all other groups it may be assigned too.
I have a way I could do it but it feels super convoluted/dirty. Build an array of all the tracks that are in the group that are not the track I want to remove than use the replace function within the group window.
figured I would ask if anyone had a better way before I do it that way?
Thanks in advance !
Jack
- Nathan Salefski @nathansalefski
Try this. You'll just have to ensure every group you have is visible in group list. I haven't found a work around for that yet:
function getGroupRows() { let editWindowMenuItem = sf.ui.proTools.getMenuItem('Window', 'Edit'); let mixWindowMenuItem = sf.ui.proTools.getMenuItem('Window', 'Mix'); if (editWindowMenuItem.isMenuChecked) { let groupRows = sf.ui.proTools.mainWindow.invalidate().groupListView.childrenByRole('AXRow'); return groupRows; } else if (mixWindowMenuItem.isMenuChecked) { let groupRows = sf.ui.proTools.mixWindow.invalidate().tables.whoseTitle.is("Group List").first.childrenByRole('AXRow'); return groupRows; } } function matchGroupsToSelection(groupRows) { sf.ui.proTools.groupsEnsureGroupListIsVisible(); let groupsContainingSelectedTrack; const targetGroupRow = groupRows.map(r => ({ groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1], btn: r.childrenByRole('AXCell').first.buttons.first.value.invalidate().value, })).filter(g => g.btn == 'Track selection partially contains group'); if (targetGroupRow) { groupsContainingSelectedTrack = targetGroupRow.map(row => row.groupName); } return groupsContainingSelectedTrack } function selectTracksInGroup(groupName, groupRows) { sf.ui.proTools.groupsEnsureGroupListIsVisible(); const targetGroupRow = groupRows.map(r => ({ groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1], btn: r.childrenByRole('AXCell').allItems[1].buttons.first, })).filter(g => g.groupName === groupName)[0] targetGroupRow.btn.popupMenuSelect({ isRightClick: true, menuPath: ['Select Tracks In Group'], }, `Group Not Visible`); } function modifyTracksInGroup(groupName, groupRows) { sf.ui.proTools.groupsEnsureGroupListIsVisible(); const targetGroupRow = groupRows.map(r => ({ groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1], btn: r.childrenByRole('AXCell').allItems[1].buttons.first, })).filter(g => g.groupName === groupName)[0] targetGroupRow.btn.popupMenuSelect({ isRightClick: true, menuPath: ['Modify...'], }, `Group Not Visible`); const modifyGroupWin = sf.ui.proTools.windows.whoseTitle.is("Modify Groups").first; modifyGroupWin.elementWaitFor(); modifyGroupWin.buttons.whoseTitle.is("Replace").first.elementClick(); modifyGroupWin.buttons.whoseTitle.is("OK").first.elementClick(); modifyGroupWin.elementWaitFor({ waitType: "Disappear" }); } function main() { sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); let groupRows = getGroupRows(); let nameOfTrackToRemove = sf.ui.proTools.invalidate().selectedTrackNames[0]; let groupsContainingTrackToRemove = matchGroupsToSelection(groupRows).filter(gn => { return gn !== '<ALL>' }); let removalGroup = sf.interaction.selectFromList({ title: 'Remove Track from Group', prompt: `Please select which Group you'd like to remove the Track from`, items: groupsContainingTrackToRemove, oKButton: 'Confirm Group', cancelButton: 'Cancel' }).list[0]; selectTracksInGroup(removalGroup, groupRows); let selectedTracksInGroup = sf.ui.proTools.invalidate().selectedTrackNames; sf.ui.proTools.trackSelectByName({ names: selectedTracksInGroup.filter(tn => { return tn !== nameOfTrackToRemove }), deselectOthers: true, }); modifyTracksInGroup(removalGroup, groupRows); alert(`${nameOfTrackToRemove} removed from ${removalGroup}`) } main();
Jack Green @Jack_Green
This works brilliantly thank you!
- In reply tonathansalefski⬆:
Nathan Salefski @nathansalefski
@chrscheuer any ideas on how to have scroll to the group given its not visible?
Christian Scheuer @chrscheuer2024-02-28 00:04:34.697Z
I don't think I ever made scrolling work well for this, although that doesn't mean it would be impossible to build. Unfortunately, I don't have time to look into it right now, but the steps would be something like:
- Check if the group list item's frame is contained within the table's frame (meaning, it's visible)
- If it's not, simulate a mouse scroll event over the table
- Repeat the check from step 1, and then repeat step 2 until the item is in fact visible
- JIn reply toJack_Green⬆:Jacob Bauman @Jacob_Bauman
Can the script be adjusted to allow users to select one or more tracks and unassign them from all current groups?