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

Various inconsistencies when detecting layer effects

Contributor ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

I've read this thread on checking for layer effects using ActionManager code: How to get the style of a  layer using photoshop scripting ??

And I'm using the below code to try and check for the bevel and emboss effect:

// Checks for bevel and emboss effect

function sTID(s){ return app.stringIDToTypeID(s); };

var ref = new ActionReference(); 

ref.putEnumerated(sTID("layer"), sTID("ordinal"), sTID("targetEnum") );  

res = executeActionGet(ref).getObjectValue(sTID("layerEffects")).hasKey(sTID("bevelEmboss"));

alert(res);

But the problem here is that it returns true for ALL layer effects. Why?

I'm using the below code to check for the stroke FX and it works as expected - but as you can see, changing the TypeID in the hasKey() -function doesn't seem to be working.

// Checks for stroke effect

function sTID(s){ return app.stringIDToTypeID(s); };

var ref = new ActionReference(); 

ref.putEnumerated(sTID("layer"), sTID("ordinal"), sTID("targetEnum") );  

res = executeActionGet(ref).getObjectValue(sTID("layerEffects")).hasKey(sTID("frameFX"));

alert(res);

Another inconsistency is that if you have multiple effects, the layer effect is sometimes not found at all - unless you manually go into the effects options and chose "delete hidden effects". You can try this with the following code for instance:

// Checks for the drop shadow effect

function sTID(s){ return app.stringIDToTypeID(s); };

var ref = new ActionReference(); 

ref.putEnumerated(sTID("layer"), sTID("ordinal"), sTID("targetEnum") );  

res = executeActionGet(ref).getObjectValue(sTID("layerEffects")).hasKey(sTID("dropShadow"));

alert(res);

TOPICS
Actions and scripting

Views

789

Translate

Translate

Report

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
Guide ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

// Checks for bevel and emboss effect function

function sTID(s){ return app.stringIDToTypeID(s); };  

var ref = new ActionReference();  

ref.putEnumerated(sTID("layer"), sTID("ordinal"), sTID("targetEnum") );   

var desc = executeActionGet(ref).getObjectValue(sTID("layerEffects"));

if(desc.hasKey(sTID("bevelEmboss"))){ 

alert("Has bevelEmboss"); 

}else{

    alert("does not have bevelEmboss");

    }

Votes

Translate

Translate

Report

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
Contributor ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

That is the same code that I use and I get false-positives with it

Update to original post:
Checking for layer effects breaks when there are two of the same layer effects active. Most likely a key error.
Bevel and Emboss is broken - It gives false positives all the time.

Satin is also broken - Like Bevel and Emboss it also gives false positives all the time.

Votes

Translate

Translate

Report

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
Guide ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

Might be down to the Photoshop version? CS6 is ok.

Votes

Translate

Translate

Report

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
Contributor ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

Possibly. I'm on CC 2017 right now.

Votes

Translate

Translate

Report

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
Contributor ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

Another update:

The keys for each layer effect change when there are multiple effects of the same kind. Example:
Say that you have one inner shadow effect. Then the key is "innerShadow". But if you have 0 or 2+ innerShadow effects then the key is "innerShadowMulti". This can be confirmed with this code:

function sTID(s){ return app.stringIDToTypeID(s); };

var ref = new ActionReference(); 

ref.putEnumerated(sTID("layer"), sTID("ordinal"), sTID("targetEnum") );  

result = executeActionGet(ref).getObjectValue(sTID("layerEffects")).getKey(2);

result = typeIDToStringID(result);

alert(result);

Now run that code in jsh on a layer with 0, 1 and 2 Inner Shadow -effects. You will get "innerShadow" when there is only 1 effect of this kind, but "innerShadowMulti" when there is 0 or 2+ effects. I've found that the reason for this behavior is different from the Satin and Bevel&Emboss -FX is that in the case of the latter two, there can only be one of a kind on a layer. In other words: a layer can have multiple drop shadow FX, but only one Bevel&Emboss. My conclusion is that in order to determine the status of all layer effects, we have to go deeper into the object.

Votes

Translate

Translate

Report

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
Contributor ,
Feb 16, 2017 Feb 16, 2017

Copy link to clipboard

Copied

LATEST

I have also discovered that once you apply a layer effect to a layer, the following keys are added to the layer effects -descriptor:

bevelEmboss

chromeFX

...and this happens even if you DON'T add these effects to the layer and even if you DO "delete hidden effects".

In other words: you have to go deeper into the object and actually have a look at the attributes -_- Why Adobe, WHY?

Votes

Translate

Translate

Report

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