Hi photoshop community!
I am familiar with javascript, but new with adobe scripting. I wrote a few first scripts, but I am now stucked with the following use case.
I have some NORMAL layers containing an image, but I have to implement the following use case:
- detect those who have a shadow filter
- duplicate them, then:
-- remove shadow filter from original one
-- delete all filters but the shadow one fro the clone
However, I am not able to retrieve the list of filters, nor test if the layer contains a shadow one.
The following threads are probably related:
- Layer Styles & Shapes (Existing Effects & Attributes): viewtopic.php?f=66&t=8197&p=40800&hilit ... 707#p40800
- How to chek if layer has styles/blending options: viewtopic.php?f=66&t=8151&hilit=shadow& ... 5cc0d3c707
Any help is appreciated!
Detect layers containing shadow filter
Re: Detect layers containing shadow filter
Here is the solution to get the list of effects:
You can use it like:
Code: Select all
function prLayerHasKey(key){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
return executeActionGet(ref).hasKey(stringIDToTypeID(key));
}
function prLayerGetObjectValue(key){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
return executeActionGet(ref).getObjectValue(stringIDToTypeID(key));
}
function prGetEffectsList(){
var effects = [];
var hasEffects = prLayerHasKey('layerEffects');
if ( hasEffects ){
var effectsObjectValue = prLayerGetObjectValue('layerEffects');
var count = effectsObjectValue.count;
for (var i = 0; i < count; i++) {
// convert ID to CHAR https://pastebin.com/h9bK3m8D
var typeID = effectsObjectValue.getKey(i);
var charID = typeIDToCharID(typeID);
effects.push(charID);
}
}
Code: Select all
app.activeDocument.activeLayer = layer;
var effects = prGetEffectsList();
if (effects.indexOf('DrSh') !== -1){
...
- Jaroslav Bereza
- Posts: 38
- Joined: Tue Dec 27, 2016 7:22 pm
Re: Detect layers containing shadow filter
You can check my sript "Clear hidden effects" http://bereza.cz/ps/
Shadow is usually array(list) but also can be without array.
And there is a lot bugs: https://feedback.photoshop.com/photosho ... gs-am-code
Good luck... otherwise you can waste a lot time.
Shadow is usually array(list) but also can be without array.
And there is a lot bugs: https://feedback.photoshop.com/photosho ... gs-am-code
Good luck... otherwise you can waste a lot time.