Applying Last Filter to smart object without dialogs

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Scott Miles

Applying Last Filter to smart object without dialogs

Post by Scott Miles »

I found the following code posted here and it works perfectly on a normal layer:

Code: Select all//  Function "Last Filter":  Reinstates the Last Filter Applied without Dialogs.

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;};

   };   //   End of Function

When I apply it to a smart object the UI for that filter pops up; evidently that's typical behavior when a last filter is applied to a smart object. I'd like to find a way to avoid this if possible.

Is there a way to code a last filter that will circumvent the filter UI when applied to a smart object?

TIA