1 Reply Latest reply on Feb 14, 2011 8:29 PM by Michael L Hale

    Help: Need  script help to delete hidden layers. Action errors using panel command.

    DevilsChariot Level 1

      I am trying to make an action (that is using some scripts) that will delete hidden layers. When I try and action that in photoshop, the actions stops for an error if the file didn't have any hidden layers. I think I need to script it so it will delete the hidden layers, and keep going if there aen't any.

       

      I couldnt find anything in th ejavascript ref guide for doing this. ( I'm sure I was looking right at it, I am a noob).

       

      Thanks for any help you can give.

        • 1. Re: Help: Need  script help to delete hidden layers. Action errors using panel command.
          Michael L Hale Level 5

          Here is a script to will delete hidden layers but not throw an error is there are no hidden layers.

          try{
               var desc = new ActionDescriptor();
               var ref = new ActionReference();
               ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), stringIDToTypeID( "hidden" ) );
               desc.putReference( charIDToTypeID( "null" ), ref );
               executeAction( charIDToTypeID( "Dlt " ), desc, DialogModes.NO );
          }catch(e){}
          

          Note you could also do this with just actions steps. Have the action add a layer then hide it before the delete hidden layers menu item step. That way there would always be at least one hidden layer and no error.