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

Stop Script execution from CEP panel.

Explorer ,
Oct 31, 2023 Oct 31, 2023

Is there a way to force an script to stop executing from CEP panel?  For example in long loops:

my first thought was to make the loop in the CEP context and pass the index and the data in each loop to an extendscript method, so I can control the loop outside, but it seems to be a little cumbersome.

 

Is there a simpler aproach?  I'm especially thinking about more complex processes with more loops and complexity layers

 

TOPICS
How to , Scripting , User interface or workspaces
521
Translate
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 ,
Oct 31, 2023 Oct 31, 2023

I don't think this is possible, unfortunately.
As you suggested, the only option is probably to do the loop in CEP and split the job into many small jsx executions. That's also what I do in Still Exporter, for example, to show a status update in the CEP panel while the images are exported.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
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
Explorer ,
Oct 31, 2023 Oct 31, 2023
I was also just thinking about it to make progress bars, although perhaps for that it would be easier to use the extendscript UI builtin tools.

 

Translate
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
Enthusiast ,
Oct 31, 2023 Oct 31, 2023

You can make your function run async with "app.scheduleTask();"  and during each loop check the global object if the execution should continue, for example:

 

if ($.["myscriptname"].continueRun === false) {
  // break the loop here and cancel task
  app.cancelTask(); //
}

 

Translate
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
Explorer ,
Oct 31, 2023 Oct 31, 2023
It seems like an interesting approach. I'm going to give it a try and tell you if that worked. Thanks

 

Translate
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
Participant ,
Mar 15, 2024 Mar 15, 2024
LATEST

Maybe not the best approach, but the way I managed to make it work is by creating stop.txt file next to the main extendscript file and when user runs functions from UI, it writes with fs and path modules to the txt file '0' which means 'don't stop', the through extendscript I added checkers that read the file and throw error if the stop.txt contains '1', error is taken care by trycatch
stop button in UI writes to stop.txt '1' which means 'stop'
ScreenFlow.gif

Translate
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