Hello, I am having difficulty restoring a saved track selection after I have closed or opened a folder track.
This is my script for it:
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.mainWindow.invalidate();
globalState.selectedTracks = sf.ui.proTools.selectedTrackNames
sf.ui.proTools.trackGetByName({ name: "HALL REC", makeVisible: true }).track.trackSelect();
sf.keyboard.press({
keys: "shift+f",
});
sf.ui.proTools.trackSelectByName({ names: globalState.selectedTracks })
What could be the problem? And is there a solution for this?
I am grateful for any help. Best regards,
Tobi
- Jack Green @Jack_Green
Someone much better than me will be along but ....
Try ...
sf.ui.proTools.invalidate();
on line 11
- TTK_Delay @TK_Delay
That's the solution, great job! Thank you so much..!
- In reply toJack_Green⬆:
Chris Shaw @Chris_Shaw2024-03-09 21:11:02.497Z
Whenever possible you should only invalidate what nneds to be invalidate.
sf.ui.proTools.invalidate()
invalidates everything in PT when changing the way tracks are displayed in the editor window it's best to usesf.ui.proTools.mainWindow.invalidate()
For a full explanation of invalidating see this article: When to use invalidate()
- In reply toTK_Delay⬆:Nathan Salefski @nathansalefski
What @Jack_Green said will work but if you can also open and close folders without changing the track selection like this:
sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); let folderTrack = sf.ui.proTools.trackGetByName({ name: "HALL REC", makeVisible: true }).track; folderTrack.openCloseFolderButton.elementClick({ executionMode: "Background" });
- TTK_Delay @TK_Delay
Nice! Thank you for your fast answer, great!
- In reply tonathansalefski⬆:
Chris Shaw @Chris_Shaw2024-03-09 21:15:48.798Z
If you're running PT 2024.12 or later and SF 5.7 or later you can use the new SDK command to open and close a folder:
sf.app.proTools.setTrackOpenState({ enabled:true, //false to close, trackNames:["HALL REC"] })
- TTK_Delay @TK_Delay
Oh nice! Thanks!