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

try...catch statement usually not working in Ps CC 2019!

LEGEND ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

Can someone explain what is going on? I ran following script in CS6 EXTENDED and found there is no problem about. Probably that doesn't occur in any later releases prior to newest CC 2019, however that I'm not sure, but in latest CC 2018 I think that worked still smoothly.

How to fix the code it worked as should? After you ran it, it's creating 10 new documents, over-saving each for web on the desktop. When randomally within this short time I stop script by pressing ESC key there happens different things, like:

- sometimes correctly intended alert pops up!

- mostly I'm hearing beep, while script is continued!

- quite often I'm getting error: 'Command could not be completed', then after pressing enter script is continued!

$.level = 0; try{

     for(i = 0; i < 10; i++) {

          opn = documents.add(), opt = new ExportOptionsSaveForWeb()

          opt.format = SaveDocumentType.JPEG, opt.optimized = true, opt.quality = 100

          opn.exportDocument(File('~/desktop/name.jpg'), ExportType.SAVEFORWEB, opt)

     }

}catch(err){alert('Operation got cancelled!')}

I reverted to 2018 twice because of some 'features' that were over my patience, now this scripting bug crosses my limit completely. If anyone knows at least some workaround please share...

I tried it in CC2018 I just installed - it's completely same, but I don't remember I ever had it with any script, why it happens?

TOPICS
Actions and scripting

Views

1.8K

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

People's Champ , Dec 09, 2018 Dec 09, 2018

Try this. Although all this is strange.

Untitled-1.png

Votes

Translate

Translate
Adobe
Enthusiast ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

If you want to cancel script I would try "app.doProgress()" this is the proper way how to do it. For new PS versions.

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
LEGEND ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

Can you show how to implement it. I tried it but it doesn't change anything, I'm having still same errors...

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
People's Champ ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

Try this. Although all this is strange.

Untitled-1.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
LEGEND ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

Okey that solves the problem! But one question: doesn't it slow down this or some more complex process? If so, how then do it normal speed way? With many documents and layers ran by some huge script 'step by step' may be unacceptable

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
People's Champ ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

I do not know

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
LEGEND ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

Re: app.system: hide command line window?  I think it only switches 'accelerated' to 'step by step' if I'm right?

Maybe that Jarda Bereza​ proposed would be the solution? Anyway thank you but latest Photoshops are weak

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
People's Champ ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

I think that the speed of the execution of the script is a plus. Although CC2018 does not differ much speed. The fact that he reacts badly to ESC is not yet an indicator of bad.
StepByStep will only slow down operations with executeAction() a bit. You can make speed measurements yourself.

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
LEGEND ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

I also tried without saving for web, but changing visibility of layers to false, and back to true, by DOM though.

I wonder if whole script would use only Action Manager that would finally be the solution for the problem?

Personally I think it's very bad you can't rely on ESC - that changes much (surely when scripts goes on).

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
People's Champ ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

Try running your script with
app.displayDialogs = DialogModes.ALL;
And click Cancel in the SaveForWab dialog.
You will not see the error even in CS6.
This is a natural bug in the implementation of the exportDocument method.

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
LEGEND ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

Actually that was my first thought before even I created this topic, but I wanted to avoid Action Manager 'Export for Web' code as that is so huge like nothing else 😕 I tried Pure Action Manager code - it failed as well, so that's error in Export code!

I assume save for web / export is covered by Generator implemented externally to Ps in some CC - that must be reason that the script stopped by user breaks. In CS6 times it worked as that wasn't connected to Ps Generator that didn't support Ps in that time yet. What do you think? I guess if I replaced 'save for Web' for JPG export it would give that specific error too.

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
People's Champ ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

LATEST

No, the generator has nothing to do with it.

I have disabled all extensions and generator in CC2018.

This is a regular plugin.
Required/Plug-ins/Import-Export/Save for Web.8be

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