How to chek if layer has styles/blending options

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

pivanov

How to chek if layer has styles/blending options

Post by pivanov »

Hi again guys,
I try to found a way how to check if some layer have a Blending options like drop shadow or border?

Do you have an idea?

Thanks in advance

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

How to chek if layer has styles/blending options

Post by Mike Hale »

You have to use Action Manger to work with layer styles. Here is one way to check to see if the activeLayer has a layer style applied.
Code: Select allvar idDrSh = charIDToTypeID( "DrSh" );// Drop Shadow
var idIrSh = charIDToTypeID( "IrSh" );// Inner Shadow
var idOrGl = charIDToTypeID( "OrGl" );// Outer Glow
var idIrGl = charIDToTypeID( "IrGl" );// Inner Glow
var idebbl = charIDToTypeID( "ebbl" );// Bevel adn Emboss
var idSoFi = charIDToTypeID( "SoFi" );// Color Overlay
var idGrFl = charIDToTypeID( "GrFl" );// Gradient Overlay
var idpatternFill = stringIDToTypeID( "patternFill" );// Pattern Overlay
var idChFX = charIDToTypeID( "ChFX" );// Satin
var idFrFX = charIDToTypeID( "FrFX" );// Stroke
      
function activeLayerHasEffects( effectID ){// effectID optional
   var hasEffect = getDescriptor(charIDToTypeID('Lyr ')).hasKey(stringIDToTypeID('layerEffects'));
   if(effectID==undefined) return hasEffect;
   return hasEffect ? !!getActiveLayerProperty(stringIDToTypeID('layerEffects'), effectID).count:false;
   
};
function getDescriptor( psClass, psKey ){// integer:Class, integer:key
   var ref = new ActionReference();
   if( psKey != undefined ) ref.putProperty( charIDToTypeID( "Prpr" ), psKey );
   ref.putEnumerated( psClass , charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
   return executeActionGet(ref);
};
function getActiveLayerProperty( psKey, psType ) {
   var ref = new ActionReference();
   ref.putProperty( charIDToTypeID( 'Prpr' ), psKey );
   ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
   if( undefined == psType ){
        return executeActionGet( ref ).getObjectValue( psKey );
   }else{
      return executeActionGet( ref );
   }
};
activeLayerHasEffects(charIDToTypeID( "DrSh" ));
pivanov

How to chek if layer has styles/blending options

Post by pivanov »

Hey Mike,
thanks a lot for your comment I want to add one more thing just for info
this works perfect ... but I use this in loop so ... I had to add this line in to the loop

Code: Select allactiveDocument.activeLayer = the_current_layer;

Thanks a lot again )
Mike Hale

How to chek if layer has styles/blending options

Post by Mike Hale »

Yes the code I posted works with the activeLayer. I have other AM code for working by index, id, or name.

So yes, if you want to check all the layers in the document you would need to add some type of loop.