Skip to main content
April 8, 2014
Question

Is it possible to loop through items/layers and change the color overlay?

  • April 8, 2014
  • 1 reply
  • 766 views

Is it possible to loop through items/layers and change the color overlay? I can get select layers but am unsure how to loop through and change the color overlay.

I am using

app.executeCommand(app.findMenuCommandId("Color Overlay"));

overlay.layerStyle.colorOverlay.color.setValue(10);

to change other properties but on Overlay it simply fails.

This topic has been closed for replies.

1 reply

UQg
Legend
April 8, 2014

Hi,

when the layers are the active comp "selected layers", it would look like this:

// new values to be set for each layer

var overlayBlendMode = 3; // 3 normally not possible, it is a separator...

var overlayColor = [0.3, 0.3, 0.3, 1];

var overlayOpacity = 75;

var comp = app.project.activeItem, n, layer, overlayGroup;

if (comp instanceof CompItem && comp.selectedLayers.length>0){

    

    app.executeCommand(app.findMenuCommandId("Color Overlay"));

    for (n=0; n<comp.selectedLayers.length; n++){

        layer = comp.selectedLayers;

        overlayGroup = layer.property("ADBE Layer Styles").property("solidFill/enabled");

        if (overlayGroup.canSetEnabled){

            // if so, it means that the overlay group has been revealed and its values can be modified

            overlayGroup.property("solidFill/mode2").setValue(overlayBlendMode);

            overlayGroup.property("solidFill/color").setValue(overlayColor);

            overlayGroup.property("solidFill/opacity").setValue(overlayOpacity);

            }

        else alert("layer("+layer.index+") overlay cannot be modified, it is not enabled.");

        };

    };

Xavier

Edit: you just edited your post so i did the same to adapt and added the line app.executeCommand(app.findMenuCommandId("Color Overlay"));

I think that what fails in your code is that 10 ... is not a color.

April 8, 2014

Is it possible to use a hexadecimal code or no?

UQg
Legend
April 8, 2014

You need to translate the hex into a [r,g,b,a].

See this thread: http://forums.adobe.com/message/5680721#5680721