Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script to remove All layer effects

Community Beginner ,
Apr 10, 2019 Apr 10, 2019

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

Screenshot at Apr 11 08-57-27.png

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.

TOPICS
Actions and scripting
3.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Beginner ,
Apr 10, 2019 Apr 10, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 10, 2019 Apr 10, 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); } 

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 10, 2019 Apr 10, 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); } 

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Apr 10, 2019 Apr 10, 2019

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

to not change layer blending mode and opacity.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Apr 11, 2019 Apr 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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 03, 2023 May 03, 2023
LATEST

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

0233F093-C43A-41CA-BEDF-A1DBAAE6460A.pngexpand image

 

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.

ACDB94BA-0EEB-49C2-9175-058DE034925B.pngexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines