Skip to main content
improstudio
Participant
April 11, 2019
Question

Script to remove All layer effects

  • April 11, 2019
  • 5 replies
  • 3661 views

Does anyone have, or know if it's possible to remove all layer effects with a script? (On every layer in the document)

Here is the example

This PSD is converted from SVG by affinity designer, unfortunately all layer have hidden effects. Currently I delete this effect one by one,  it would be great if there is a script that can delete all layer effect on document at once.

This topic has been closed for replies.

5 replies

Greg von Neulich
Known Participant
May 3, 2023

we made a Photoshop plug-in that can do this. The unlimited version is 12$. 

 

Full Version (12$):
https://exchange.adobe.com/apps/cc/c36e02fb/swift


Trial Version (Limited to 5 Actions):
https://exchange.adobe.com/apps/cc/412c1dcd/swift-trial-version

 

Its also a big help with getting the layers selected.

Legend
April 11, 2019

This will apply all effects (if you need it of course)

runMenuItem(stringIDToTypeID("selectAllLayers"));

var d = new ActionDescriptor();

var r = new ActionReference();

r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

d.putReference(stringIDToTypeID("null"), r);

d.putEnumerated(stringIDToTypeID("what"), stringIDToTypeID("rasterizeItem"), stringIDToTypeID("layerStyle"));

executeAction(stringIDToTypeID("rasterizeLayer"), d, DialogModes.NO);

runMenuItem(stringIDToTypeID("selectNoLayers"));

upd.

You can also insert a command "hide effects" before rasterization

var d = new ActionDescriptor();

var r = new ActionReference();

r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerFXVisible"));

r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

d.putReference(stringIDToTypeID("null"), r);

var d1 = new ActionDescriptor();

d1.putBoolean(stringIDToTypeID("layerFXVisible"), false);

d.putObject(stringIDToTypeID("to"), stringIDToTypeID("layerFXVisible"), d1);

executeAction(stringIDToTypeID("set"), d, DialogModes.NO);

greless
Inspiring
April 11, 2019

Make an adjustment

try{

    var ref = new ActionReference();

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

    var applicationDesc = executeActionGet(ref);

    var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));

    for (var m = 0; m <= theNumber; m++)

    {

        var ref = new ActionReference();

        ref.putIndex( charIDToTypeID( "Lyr " ), m);

        var layerDesc = executeActionGet(ref);

        var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));

        var ID = layerDesc.getInteger(stringIDToTypeID('layerID'));

        SelectLayer(ID);

        if ( isBackground != true &&  haslayerEffects())

                {

                    disableLayerStyle();

                 }

    }

}catch(e){alert(e)}

function haslayerEffects()

    {

    try {

        var d = new ActionDescriptor();

        var r = new ActionReference();

        r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

       var options = executeActionGet(r); 

        return options.hasKey(stringIDToTypeID("layerEffects"))

        }

    catch (e) {alert(e) }

    }

function disableLayerStyle()

    {

    try {

        var d = new ActionDescriptor();

        var r = new ActionReference();

        r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

        d.putReference(stringIDToTypeID("null"), r);

        executeAction(stringIDToTypeID("disableLayerStyle"), d, DialogModes.NO);

        }

    catch (e) {alert(e) }

    }

function SelectLayer(ID)

   {

        try{

                 var r = new ActionReference(); 

                 var d = new ActionDescriptor();

                //    r.putName(stringIDToTypeID("layer"), "图层 2");

                r.putIdentifier(stringIDToTypeID("layer"), ID);

                //   r.putIndex(stringIDToTypeID("layer"), "0");

                 d.putReference(stringIDToTypeID("null"), r);

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

             }

        catch(e){ alert(e); } 

    }

Legend
April 11, 2019

It is better to use "disableLayerFX" instead "disableLayerStyle"

to not change layer blending mode and opacity.

greless
Inspiring
April 11, 2019

i have a stupid idea

try{

    var ref = new ActionReference();

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

    var applicationDesc = executeActionGet(ref);

    var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));

    for (var m = 0; m <= theNumber; m++)

    {

        var ref = new ActionReference();

        ref.putIndex( charIDToTypeID( "Lyr " ), m);

        var layerDesc = executeActionGet(ref);

        var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));

         var theName = layerDesc.getString(stringIDToTypeID('name'));

         SelectLayer(theName,m);

        if ( isBackground != true &&  haslayerEffects())

                {

                    disableLayerStyle();

                 }

    }

}catch(e){alert(e)}

function haslayerEffects()

    {

    try {

        var d = new ActionDescriptor();

        var r = new ActionReference();

        r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

       var options = executeActionGet(r); 

        return options.hasKey(stringIDToTypeID("layerEffects"))

        }

    catch (e) {alert(e) }

    }

function disableLayerStyle()

    {

    try {

        var d = new ActionDescriptor();

        var r = new ActionReference();

        r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

        d.putReference(stringIDToTypeID("null"), r);

        executeAction(stringIDToTypeID("disableLayerStyle"), d, DialogModes.NO);

        }

    catch (e) {alert(e) }

    }

function SelectLayer(Layername,ID)

   {

        try{

                 var r = new ActionReference(); 

                 var l = new ActionList();

                 var d = new ActionDescriptor();

                 r.putName(charIDToTypeID("Lyr "),Layername);

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

                 l.putInteger(ID);

                 d.putList(  charIDToTypeID( "LyrI" ), l );

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

             }

        catch(e){ alert(e); } 

    }

improstudio
Participant
April 11, 2019

Ah my bad, Jarda Bereza​ have the script. Thank you Magic scripts for Photoshop