Skip to main content
Known Participant
December 20, 2019
Answered

How can I tell if a layer has a layer style by using a script?

  • December 20, 2019
  • 3 replies
  • 2675 views

I want to use a script to find out which layers have layer styles, but I haven't found relevant information. Does anyone know how to do this?

 

Subject modified by Moderator

This topic has been closed for replies.
Correct answer JJMack

If you use Google Search you can find code to do that on this site.  You will find code like this. Test if activeLayer has a layer effect.

 

 

 

 

 

alert(haslayerEffects());

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

 

 

 

 

 

I extracted that from script to remove all layer effects 

 

You often need to use Action manager code which I do not know how to code I can hack on the action manager code Adobe scriplistener plug-in records. However, for the executeActionGet  code required the get information I need to use search and find. It would be better if this web site search was useable.

3 replies

MrDesignAuthor
Known Participant
December 20, 2019

Thank you very much for your answer, it really works and the code is elegant.

JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
December 20, 2019

If you use Google Search you can find code to do that on this site.  You will find code like this. Test if activeLayer has a layer effect.

 

 

 

 

 

alert(haslayerEffects());

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

 

 

 

 

 

I extracted that from script to remove all layer effects 

 

You often need to use Action manager code which I do not know how to code I can hack on the action manager code Adobe scriplistener plug-in records. However, for the executeActionGet  code required the get information I need to use search and find. It would be better if this web site search was useable.

JJMack
MrDesignAuthor
Known Participant
December 20, 2019

Thank you very much for your answer, it really works and the code is elegant.

December 20, 2019

Hi

You can filter the layers by effects

MrDesignAuthor
Known Participant
December 20, 2019

Thank you for your answer. Unfortunately, it's not what I want. I mean to use script to judge whether a layer has a style

Leslie Moak Murray
Community Expert
Community Expert
December 20, 2019

Do you mean when a layer style has been applied but is now rasterized so it can't be separated into its own layer, and there's no way (other than eyeballing it and guessing) to tell what it was (i.e. inner shadow, inner glow, etc as in the dropdown shown in Ged's reply)?