0 Replies Latest reply on Nov 21, 2014 4:01 PM by jasonharringtonstudios

    Apply Last Filter (Liquify) on Selected Layers and Groups


      I am trying to alter a script for applying the last filter. But using the last Liquify mesh, the script errors out and says that the user has selected to cancel the action. Sometimes it works but most of the time, not. Script code is below too.


      I am wondering if there's anyone that can help update this amazing tool.




      #target Photoshop




      function main(){

      if(!documents.length) return;

      var selLayers=[];

      selLayers= getSelectedLayersIdx();

      for (var a in selLayers){

          makeActiveByIndex( selLayers[a], false );





      function getSelectedLayersIdx(){

            var selectedLayers = new Array;

            var ref = new ActionReference();

            ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

            var desc = executeActionGet(ref);

            if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){

               desc = desc.getList( stringIDToTypeID( 'targetLayers' ));

                var c = desc.count

                var selectedLayers = new Array();

                for(var i=0;i<c;i++){



                     selectedLayers.push(  desc.getReference( i ).getIndex() );


                     selectedLayers.push(  desc.getReference( i ).getIndex()+1 );




               var ref = new ActionReference();

               ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));

               ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );



                  selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);


                  selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));



            return selectedLayers;


      function makeActiveByIndex( idx, visible ){

          var desc = new ActionDescriptor();

            var ref = new ActionReference();

            ref.putIndex(charIDToTypeID( "Lyr " ), idx)

            desc.putReference( charIDToTypeID( "null" ), ref );

            desc.putBoolean( charIDToTypeID( "MkVs" ), visible );

         executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );


      function lastFilter(){

      var d = new ActionDescriptor();

      var r = new ActionReference();

      r.putEnumerated( charIDToTypeID('Mn  '), charIDToTypeID('MnIt'), charIDToTypeID('LstF') );

      d.putReference( charIDToTypeID('null'), r );

      try{executeAction( charIDToTypeID('slct'), d, DialogModes.NO );}catch(e){alert(e+" "+e.line);return;};