Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: Apply new color to layers

$
0
0

Hi, thank you for your help!

 

However, I'm having problems running the script. The first time it runs on a photoshop file it works fine, deletes all Color Overlay styles from "fillMe" layers and fills the according layers with the foreground color.

When it runs a second time it always stops with the prompt "The command 'delete layer style' is momentarily not available" (or the German counterpart to that sentence).

I tried to incorporate your code into mine, but I don't know what I'm doing wrong...

 

function recolor(layerNode) {   

    for (var i=0; i<layerNode.length; i++) {

 

 

        recolor(layerNode[i].layerSets);

 

 

        for(var layerIndex=0; layerIndex < layerNode[i].artLayers.length; layerIndex++) {

            var layer=layerNode[i].artLayers[layerIndex];

            if (layer.name == "fillMe") {

                layer.visible = 1;

                layer.transparentPixelsLocked = 1;

                app.activeDocument.activeLayer = layer;

                var ref = new ActionReference();

                ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

                var layerDesc = executeActionGet(ref);

                if (layerDesc.hasKey(stringIDToTypeID('layerEffects')) == true) {

                    delColOverlay();

                }

                fillWithNewColor();

                app.runMenuItem(stringIDToTypeID('selectNoLayers'));

            }

           

        }

    }

}

 

 

 

 

function fillWithNewColor(){

    var idFl = charIDToTypeID( "Fl  " );

    var desc137 = new ActionDescriptor();

    var idUsng = charIDToTypeID( "Usng" );

    var idFlCn = charIDToTypeID( "FlCn" );

    var idFrgC = charIDToTypeID( "FrgC" );

    desc137.putEnumerated( idUsng, idFlCn, idFrgC );

    executeAction( idFl, desc137, DialogModes.ALL );

};

 

 

function delColOverlay(){

    var iddsfx = charIDToTypeID( "dsfx" );

    var desc173 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

    var ref77 = new ActionReference();

    var idSoFi = charIDToTypeID( "SoFi" );

    ref77.putClass( idSoFi );

    var idLyr = charIDToTypeID( "Lyr " );

    var idOrdn = charIDToTypeID( "Ordn" );

    var idTrgt = charIDToTypeID( "Trgt" );

    ref77.putEnumerated( idLyr, idOrdn, idTrgt );

    desc173.putReference( idnull, ref77 );

    executeAction( iddsfx, desc173, DialogModes.ALL );   

};

recolor(app.activeDocument.layerSets);


Viewing all articles
Browse latest Browse all 27456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>