How to detect if clips are present in a selection
Hey!
I've hit a stumbling block in my recent script.
Is there a way to detect if there are any clips present within a timeline selection over a number if tracks.
Tried to see if I could use "if a menu item is enabled" but I couldn't find a menu item that was different whether clips were present or not.
It'll form part of a longer script where this will be a function to "check if there are clips". If there are clips do an action, if there are no clips move on to next part of script.
Does that make sense? All help greatly appreciated.
Many thanks,
Iain
- Kitch Membery @Kitch2020-11-14 02:56:22.192Z
Hi @Iain_Anderson,
Initially I was thinking you could use the
selectionGetInfo()
for this;However I found it not the better solution as the 'hasPartialClip' only returns true if there is no other blank space selected.
I did however see that when audio exists in the selection the Trim to selection Menu item is enabled, so checking if it exists would be the best way to go.
Like this;
sf.ui.proTools.appActivateMainWindow(); const audioExists = sf.ui.proTools.getMenuItem('Edit', 'Trim Clip', 'To Selection').isEnabled; if(audioExists){ log('Audio Exists in the selection!') } else { log('Audio does not Exist in the selection') }
Hope that helps!
- IIain Anderson @Iain_Anderson
Hi Kitch,
Thanks for the suggestion. That seems to work if the selection is on one track, however, it doesn't work if the selection is across many tracks. This is the issue i'm having.
Would not having a selection in the clip list work? How would I script that?
I've attached a few screenshots to demonstrate what i'm after.
Image 1 should return "No Audio Here", Image 2 should return "There is Audio Here".
Thanks,
Iain
Kitch Membery @Kitch2020-11-23 11:01:08.516Z
Hi @Iain_Anderson,
Sorry... I must have missed this post. I tested my above script and it seems to work for me in the scenarios you showed above, over multiple tracks.
Is this part of a bigger script? If so can you share the script you are working on? That way I may be able to see the problem.
Rock on!
- In reply toIain_Anderson⬆:Ingo Pusswald @ingo_luftrausch
Any updates on this?