6 Replies Latest reply on Jun 13, 2013 11:20 PM by dgolberg

    Detect or Suppress Action errors during script automation

    dgolberg Level 1

      I've run into an issue with the automation of one of my Photoshop scripts where it can be completely halted by an error in a supporting action set.  The script does about 99% of the work, but the remaining 1% has to be done in an action due to the work being done (the work is NOT scriptable, or at least not efficient in the least to put to script).  The problem I'm running into is that, if there is an error in the layer name in the action, Photoshop pops up an alert about the issue, halting the whole process until I click the "Ok" button on said alert.

       

      Is there any way to catch these errors (a simple try/catch on the action activation code doesn't work), or at least suppress the errors so they don't halt the entire process?  Catching the error so it can be reported via my current reporting method would be ideal, if possible.  Thanks in advance for any help!

       

      Edit: Correction on the error type; it's not an "Ok" alert, it's a "Continue/Stop" alert.  The message accompanying it is "The object "layer "layerName"" is not currently available".  This happens if the person creating the action failed to rename the layer correctly before performing their work on it in the recorded action, and halts the entire automation process until I click continue or stop.

        • 1. Re: Detect or Suppress Action errors during script automation
          Muppet Mark Level 5

          Have you script test the condition before calling the action…? 1% needs to be done by action explain why…?

           

          If you are using the the standard DOM and you script is tooooo slooow (lots of layers) look to use action manager syntax instead…

           

          If its recordable with PS action then… I thinks its about 99% doable with action manager… Dump your external resource…

          • 2. Re: Detect or Suppress Action errors during script automation
            dgolberg Level 1

            It's an extremely complex script for automating the saving out of items from a .psd file.  The action is used to record the custom distortion of some items in the project, and since each project's layout changes, so too does the distortion.  In some rare cases, the distortion becomes complex enough that it needs a couple of layers to get it to look right; this is when this error can come up.  The code I use for the action itself is below:

             

             

                try{

                    actionName = "actionName";

                    app.doAction(actionName, "actionSet");

                }

                catch (e) {

                    try {

                        actionName = "actionName";

                        app.doAction(actionName, "actionSet");

                    } catch(e) {

                        errorLog.push("The " + actionName + " action could not be found.");

                        return;

                    }

                }

            Problem is, the nested try/catch will only catch if the action's set or action name are incorrect.  If there is an issue inside the action itself, it halts the entire process until I confirm whether to continue or stop the action.  It's a "rare" occurance that I've already seen a couple of times on our automation machine which has been running for only a couple of months.  The whole point of the external machine is to send it a project, have it automatically process it and spit out the processed files so the people doing the actual work don't have to sit at their machine and watch it blink through files for 2 hours while it auto-saves everything (essentially, it's a render farm).  In other words, I need this machine to become completely hands-off.  If there is an issue, it should report it so the project can be fixed externally by the person that originally created it, then resent to the render farm.  Make sense?

            • 3. Re: Detect or Suppress Action errors during script automation
              xbytor2 Level 4

              I thinks its about 99% doable with action manager…

               

              Actions are  (almost) 100% translatable to JavaScript with http://ps-scripts.cvs.sourceforge.net/viewvc/ps-scripts/xtools/xapps/ActionToJavascript.js x.

               

              The interface is real simple and it generates a .jsx file with a function for the action that you select. It's a direct translation to Action Manager-style code. You can insert a try/catch block in there as needed.

               

              There are a couple of borderline cases that the script can't handle because the ActionDescriptor class (which the script uses) doesn't encode them.

              • 4. Re: Detect or Suppress Action errors during script automation
                dgolberg Level 1

                Interesting, never saw that before.  I'll try it out and see how I can work it into the workflow.

                • 5. Re: Detect or Suppress Action errors during script automation
                  dgolberg Level 1

                  Sorry, been extremely busy with a sudden high-priority project, so I haven't had a chance to try this out yet.  I'll be sure to post my findings once I do though.  Just didn't want you guys to think I'd forgotten about this thread.

                  • 6. Re: Detect or Suppress Action errors during script automation
                    dgolberg Level 1

                    Well, I finally got some time to play around a little with the code you linked me to and can certainly say that it did what I need it to once I found and loaded the xtools.  Now I just need to figure out how to add this into the automated script, but that's the fun part!  Thanks a ton xbytor2!