Photoshop multyply Layer Effect execution

Hello, i have a task to get all solidFill effects by layer, get color from each and put it to layer name. I test it with one “Color Overlay” effect and its work. But that shld i do for execute several “Color Overlay” effects?
I need to put each color from each “Color Overlay” effect to name by hex. My code for one effect:

if (BridgeTalk.appName == "photoshop")
{
    var doc = app.activeDocument;
    var layers = activeDocument.artLayers;
    for (var i=0; i<layers.length; i++)
    {
        doc.activeLayer = layers[i];
        solidFill();
    }
}


function solidFill()
{
    var fxDesc = getFxDesc();
    
    doc.activeLayer.name = fxDesc.p    
    
    var solidDesc = getSolidFillDesc(fxDesc);        
}

function modifyLayerName(desc)
{    
    var colObj = desc.getObjectValue(stringIDToTypeID("color"));

    var redHex = (0 + colObj.getDouble(charIDToTypeID("Rd  ")).toString(16)).slice(-2);
    var grnHex = (0 + colObj.getDouble(charIDToTypeID("Grn ")).toString(16)).slice(-2);
    var blHex = (0 + colObj.getDouble(charIDToTypeID("Bl  ")).toString(16)).slice(-2);

    doc.activeLayer.name = '#' +  redHex + grnHex + blHex;
}

function getFxDesc(){
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var desc = executeActionGet(ref);
    if(desc.hasKey(stringIDToTypeID('layerEffects'))){
        var fxDesc = desc.getObjectValue(stringIDToTypeID('layerEffects'));        
    }
    if(undefined != fxDesc) return fxDesc; 
    else doc.activeLayer.name = "nothing";
};

function getSolidFillDesc(desc)
{
    if(desc.hasKey(stringIDToTypeID('solidFill'))){
        var solidFillDesc = desc.getObjectValue(stringIDToTypeID('solidFill'));
    }
    if(undefined != solidFillDesc) return solidFillDesc;
}

plz help me: how should i get all “Color Overlay” effect by layer?

You need to check if the layerEffects descriptor has the solidFillMulti property, which includes all solid fills as an array. If it’s undefined, you can get the (potentially one) solid fill from the solidFill property like you’re already doing.

so why each elemnt of solidFillMulti have not object “color” ? What request i need to get color value?

It does:

Don’t forget that solidFillMulti is an array, so the individual objects in it have the color property, not solidFillMulti itself.

I’d write it something like this:

function getSolidFill(){...}
function getSolidFillMulti(){...}
function rgbToHex(){...}

const solidFillMulti = getSolidFillMulti()
const colors = solidFillMulti ? solidFillMulti.map(sf => sf.color) : [getSolidFill().color]
const layerName = colors.map(color => rgbToHex(color)).join(",")

thank you. I try just enumirate array, like for(var sf in solidFillMulti) and its return the properties value, its frustrating. Thx for js lesson, it looks good.
Tell me plz, where i can get info (you screen) like this?

It’s a screenshot from @Jarda’s Alchemist plugin :slight_smile:

1 Like