• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Automation Blocks - Selection Confirmation

Contributor ,
Nov 18, 2024 Nov 18, 2024

Copy link to clipboard

Copied

I'm trying to set up a script that "If" a file is selected, then do something on it, if not, I'd like to throw an error to do something else.

If Selected Duration.png

I'm setting up the variable Selected Duration that polls the duration of a selected item (for the A side of the logic), but if nothing is selected, it throws an error.

Selected Duration.png

There is an alert that comes up in the library tab and in the console "execution result:"please select exactly one project item in the project panel (line 1)"". I just want to do something actionable based on this result to fix it since users might not see either of these alerts.

 

Problem is, I can't seem to find check if something is selected or not. Maybe I'm going about this all wrong by testing the duration of a selection, but I can't figure a way to test if something is selected or not.

 

Any recommendations on how to solve this would be, as always, appreciated.

TOPICS
How to , Scripting

Views

191

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 18, 2024 Nov 18, 2024

You need to retrieve the list of selected project items (make sure to check the "only selected items" checkbox) and then check if the length of that list is equal to 1.

Votes

Translate

Translate
Community Expert ,
Nov 18, 2024 Nov 18, 2024

Copy link to clipboard

Copied

You need to retrieve the list of selected project items (make sure to check the "only selected items" checkbox) and then check if the length of that list is equal to 1.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 18, 2024 Nov 18, 2024

Copy link to clipboard

Copied

Thank you. That's perfect!

And so anyone can see how it's done, here's what I came up with. For no selected footage, it runs one function block, for when one footage is selected, it runs another, and it puts up an alert dialog reporting that there is more than one footage is selected.

Selection Confirmation.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2024 Nov 18, 2024

Copy link to clipboard

Copied

Thanks for sharing your solution!
Extra tip: You can save your list in a variable to make the code more compact (and also execute a tiny bit faster, since the list needs to be calculated only once):
Screenshot 2024-11-19 at 07.56.30.png

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 19, 2024 Nov 19, 2024

Copy link to clipboard

Copied

LATEST

This is even better!

I did note when implementing this idea that using the "length of" block was unnecessary, since the "selected items" list produces a number.

LengthOf.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines