Edit tools toggle question
Hi!
I wrote this little piece of code to be able to toggle between Trimmer/Selector and Grabber Tools in Pro Tools.
I NEVER want to use the "sub-tools", my goal is to toggle between the 3 main tools)
//selector tool variable
var selectorTool = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Cursor Tool Cluster").first.buttons.whoseTitle.is("Selector tool").first;
//grabber tool variables
var grabberTool = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Cursor Tool Cluster").first.buttons.whoseTitle.is("Grabber tool (Time)").first;
var splitgrabberTool = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Cursor Tool Cluster").first.buttons.whoseTitle.is("Grabber tool (Separation)").first;
var objectgrabberTool = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Cursor Tool Cluster").first.buttons.whoseTitle.is("Grabber tool (Object)").first;
//trimmer tool variables
var trimmerTool = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Cursor Tool Cluster").first.buttons.whoseTitle.is("Trim tool").first;
var stretchtrimmerTool = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Cursor Tool Cluster").first.buttons.whoseTitle.is("Time Compression/Expansion Trim tool").first;
var scrubtrimmerTool = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Cursor Tool Cluster").first.buttons.whoseTitle.is("Scrub Trim tool").first;
var looptrimmerTool = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Cursor Tool Cluster").first.buttons.whoseTitle.is("Loop Trim tool").first;
//Toggle command
if(selectorTool.value.invalidate().value === "Selected") {
grabberTool.elementClick();
} else if (grabberTool.value.invalidate().value === "Selected") {
trimmerTool.elementClick();
} else {
selectorTool.elementClick();
}
I created all the variables corresponding to the tools and subtools.
With this actual script, when toggling from the main tools, there are no problems, but when let's say the TIMESTRETCH trimmer is activated, the script fails.
How can I work this out? I guess I'd have to do something along the lines of
if grabberTool.value.inv or splitgrabberTool or objectgrabberTools is selected then select trimmerTool
Any idea?
- samuel henriques @samuel_henriques
Hey Thomas,
I made this a while ago, give it a try.
sf.ui.proTools.appActivateMainWindow(); const { trimTool, selectorTool, grabberTool, smartTool } = sf.ui.proTools.mainWindow.cursorToolCluster; const isTrimTool = trimTool.value.invalidate().value === 'Selected'; const isSelectorTool = selectorTool.value.invalidate().value === 'Selected'; const isGrabberTool = grabberTool.value.invalidate().value === 'Selected'; const isSmartTool = smartTool.value.invalidate().value === 'Selected'; /**@type {'Trim' | 'Selector' | 'Grabber' | 'Smart'} */ let newTool = 'Trim'; if (isSmartTool) newTool = 'Trim'; else if (isTrimTool) newTool = 'Selector'; else if (isSelectorTool) newTool = 'Grabber'; else if (isGrabberTool) newTool = 'Smart'; sf.ui.proTools.toolsSelect({ tool: newTool });
Chris Shaw @Chris_Shaw2021-07-03 19:48:40.848Z
Very slick…
samuel henriques @samuel_henriques
Hi Chris, really appreciate, thank you.
samuel henriques @samuel_henriques
Actually this is not my script, I was filling with this idea, but Christian made it for me.
Chris Shaw @Chris_Shaw2021-07-04 02:47:31.678Z
Ahh ok.
That first line is the slick part.samuel henriques @samuel_henriques
Yep, and the
**@type
. when I posted, I started to wonder how I'd come up with these and with a bit of investigation it was pretty evident I didn't 😂!
- In reply tosamuel_henriques⬆:
Chris Shaw @Chris_Shaw2021-07-03 19:58:32.979Z
@Thomas_Gloor : If you don't want to cycle the smart tool just delete the line:
else if (isGrabberTool) newTool = 'Smart';
- In reply tosamuel_henriques⬆:TThomas Gloor @Thomas_Gloor
I tried it! It now doesnt fail when another sub tool is selected, but when let's say the "time stretch" trim tool is selected, it moves on to the selector and doesn't move any more...It does work perfectly when a GRABBER sub tool is selected.
Any idea?
samuel henriques @samuel_henriques
You are right, are you on pt 2021.6? I'm on 2022.6 and it is behaving as you say. The way the buttons have "selected" value might have changed.
I'll figure out another way.samuel henriques @samuel_henriques
In the mean time, if you don't mind reseting trim and grabber to the standard position, this should do it:
sf.ui.proTools.appActivateMainWindow(); const { trimTool, selectorTool, grabberTool, smartTool } = sf.ui.proTools.mainWindow.cursorToolCluster; const isTrimTool = trimTool.value.invalidate().value === 'Selected'; const isSelectorTool = selectorTool.value.invalidate().value === 'Selected'; const isGrabberTool = grabberTool.value.invalidate().value === 'Selected'; const isSmartTool = smartTool.value.invalidate().value === 'Selected'; if (trimTool.title.invalidate().value != 'Trim tool') { trimTool.popupMenuSelect({ menuPath: ['Standard'], isRightClick: true }) } if (grabberTool.title.invalidate().value != 'Grabber tool (Time)') { grabberTool.popupMenuSelect({ menuPath: ['Time'], isRightClick: true }) } /**@type {'Trim' | 'Selector' | 'Grabber' | 'Smart'} */ let newTool = 'Trim'; if (isSmartTool) newTool = 'Trim'; else if (isTrimTool) newTool = 'Selector'; else if (isSelectorTool) newTool = 'Grabber'; else if (isGrabberTool) newTool = 'Smart'; sf.ui.proTools.toolsSelect({ tool: newTool });
- TThomas Gloor @Thomas_Gloor
thank you it works perfectly!
I run PT 2020.12.0
Do you have a way to avoid the popup menu?
Thank you so much!
samuel henriques @samuel_henriques
This is not ideal, since it doesn't "know" which tool is selected, but will circle them.
Just out of curiosity, why is this better than using the F6, F7, F8?Let me know if you want to remove the Smart tool:
sf.ui.proTools.appActivateMainWindow(); if (globalState.newTool === undefined) { globalState.newTool = 'Smart' } if (globalState.newTool === 'Smart') { globalState.newTool = 'Trim' } else if (globalState.newTool === 'Trim') { globalState.newTool = 'Selector' } else if (globalState.newTool === 'Selector') { globalState.newTool = 'Grabber' } else if (globalState.newTool === 'Grabber') { globalState.newTool = 'Smart' } sf.ui.proTools.toolsSelect({ tool: globalState.newTool });
- TThomas Gloor @Thomas_Gloor
Thank you! It's exactly what I was looking for! I modified it so it doesn't use the Smart Tool.
Well, It might sound stupid, but I have a two stream decks. One on the left hand side of the keyboard and one above in the center.
The left one is basically used for editing shortcuts, etc etc. I added very common short cuts so my hand can stay on it, and also to avoid keyboard shortcuts that twist my hand.
- TThomas Gloor @Thomas_Gloor
I did however leave
if (globalState.newTool === undefined) { globalState.newTool = 'Smart' }```` should I replace SMART by Trim or Grabber?
samuel henriques @samuel_henriques
Cool, doesn't sound stupid at all, everyone has their own workflow. I always learn something new.
without the smart tool it should be like this, you should restart SoundFlow after applying this code.
the line:
if (globalState.newTool === undefined) { globalState.newTool = 'Trim' }
is there to make sure
globalState.newTool
has a value. When you restart SoundFlow,globalState
values are lost. Without this line, every time you restart, the script won't work.if (globalState.newTool === undefined) { globalState.newTool = 'Trim' } if (globalState.newTool === 'Trim') { globalState.newTool = 'Selector' } else if (globalState.newTool === 'Selector') { globalState.newTool = 'Grabber' } else if (globalState.newTool === 'Grabber') { globalState.newTool = 'Trim' } sf.ui.proTools.toolsSelect({ tool: globalState.newTool });
- TThomas Gloor @Thomas_Gloor
Hey @samuel_henriques
Thank you so much again.One more question. I have a toggle command to flip between SLIP and ABS GRID mode. It fails when the grid is in REL GRID.
var grid = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Edit Mode Cluster").first.buttons.whoseTitle.is("Absolute Grid mode").first; var relgrid = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Edit Mode Cluster").first.buttons.whoseTitle.is("Relative Grid mode").first; var slip = sf.ui.proTools.mainWindow.groups.whoseTitle.is("Edit Mode Cluster").first.buttons.whoseTitle.is("EditModeSlip").first; if(grid.value.invalidate().value === "Selected") { slip.elementClick(); } else { grid.elementClick() }
Do you have a variant of your EDIT TOOL TOGGLE for this? That would not fail but just stay in rel grid, or even better, switch to abs grid and move on?
Best,
T.
samuel henriques @samuel_henriques
Hi Thomas,
Could you post this question on a new thread, please, just so it's easier for others to find in the future.
I'll try something and let you know.- TThomas Gloor @Thomas_Gloor
Samuel,
Will do now!
- TThomas Gloor @Thomas_Gloor
Hey @samuel_henriques !
I noticed something weird with the edit tools toggle
Sometimes it doesnt fully switch the tool before I click (anywhere in the timeline)
Any idea?
Best,
T
samuel henriques @samuel_henriques
Not being able to reproduce the problem.
Try to notice more details, like just did something to pro tools, or just opened session...
In the mean time, you can try to activate pro tools, put this line at the start of the script,sf.ui.proTools.appActivateMainWindow();
- TThomas Gloor @Thomas_Gloor
ok. let's see :)
this line was already in!
Thank you anyway :)
samuel henriques @samuel_henriques
ahh, yes it was I was looking to the wrong post.
If you get any hits let me know, and I'll try as well.