Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How do I add Layer Styles to a Layer with script?

  • How do I add Layer Styles to a Layer with script?

    Posted by Mattias Svendsen on September 21, 2011 at 12:56 pm

    Im creating automated ae files using jsx as templates, filled with folder and renderdata using Python. The goal is to have no interaction within AE, everything finished, layered and so on ready for render. Repetetive stuff.

    So my question now is how do I add Layer Styles and then change their values to a Layer with script? Basic example please, i need to use Stroke and set width, position(outside) and color.

    I also need to know how to script an empty Comp in a Comp, is there a way without going around precompose?

    Thanks / Mattias

    Xavier Gomez replied 9 years, 9 months ago 6 Members · 9 Replies
  • 9 Replies
  • Mattias Svendsen

    September 23, 2011 at 1:53 pm

    shapeLayer1(“Effects”).addProperty(“Grow Bounds”);

    shapeLayer1(“Layer Styles”).addProperty(“Stroke”);
    Doesn’t work

    Extendscript reports:
    After Effects error: Can not add a property with name “Stroke” to this …tyGroup is neither an INDEXED_GROUP nor a text animator prperty group.

    ? Any hints anyone?

  • Dan Ebberts

    September 23, 2011 at 3:11 pm

    If you figure out how to do that, please let me know. I have been completely unsuccessful.


  • Mattias Svendsen

    September 27, 2011 at 7:42 am

    Thank you for responding Dan. Seriously Adobe, what the… Im from a maya scripting background and the lack of support in after effects scripting is unprofessional. Im used to deep diving into stuff but Ive been at it for a week and find it rather hard to get into it, not because its tough to program, but the lack of information. (Rant over)

    I worked around not being able to use Layer Style/Stroke with

    var linearWipe = item.layers[1]("Effects").addProperty("Linear Wipe");
    var solidComposite = item.layers[1]("Effects").addProperty("Solid Composite");
    var miniMax = item.layers[1]("Effects").addProperty("Minimax");
    var levels = item.layers[1]("Effects").addProperty("Levels");

    and then oversizing a precomp to get rid of edge artifacts.
    Thank you Filip Vandueren!

  • John Donley

    October 3, 2011 at 5:30 pm

    I’m having the same trouble, but Im trying to use “inner shadow” which does not have an Effect equivalent.

    I can set Layer Style values if that layer style is already turned on in the gui, but I cant figure out how to turn on any layer styles.

    If I try to set a value on a layer style that has not been enabled by hand it gives me an error “Can not “set value” with this property, because the property or parent property is hidden”

    But if I set that layers style to enabled I get another error “Can not set enabled on this property because canSetEnabled is false”, but canSetEnabled is read only, so I have no idea how to turn on the layer style.

    Any thoughts?

    //This will change the opacity of the inner shadow on a layer with inner shadow turned on already
    var layer_1 = test_comp.layer(1)"Layer Styles").property("Inner Shadow")("Opacity").setValue(10)

  • Jürgen Hackl

    July 31, 2012 at 1:09 pm

    I’m having the same problems with my script, I can’t enable Layer Styles. Did anyone find a solution in the meantime?

    I want to write a expression to a color overlay in a text layer, first I tried this code:“ADBE Layer Styles”).property(“solidFill/enabled”).property(“solidFill/color”).expression = myExpressionString;

    Error: AE says that “set expression” is not possible because the property is hidden/disabled (I don’t know the error message of an english AE Version)

    Then I tried to add the Property first with this syntax and got the same Error Mattias described in the initial posting.“ADBE Layer Styles”).addProperty(“solidFill/enabled”);

    Error: Can not add a property with name … is neither an INDEXED_GROUP nor a text animator prperty group.


  • Dan Ebberts

    July 31, 2012 at 3:04 pm

    Do you have CS6? If so, you should be able to give focus to the comp viewer, select the appropriate layer, and execute the menu command to add the layer style. Something like this:

    var myCompName = "Comp 1";

    var myComp = null;
    for (var i = 1; i <= app.project.numItems; i++){
    if (app.project.item(i).name == myCompName && app.project.item(i) instanceof CompItem){
    myComp = app.project.item(i);
    if (myComp){
    myComp.layer(1).selected = true;
    app.executeCommand(app.findMenuCommandId("Color Overlay"));


  • Jürgen Hackl

    August 6, 2012 at 3:12 pm

    Hi Dan,

    thank you for your help. This solution works perfect.
    I got the command ID by using alert(app.findMenuCommandId(“Farbüberlagerung”)) and put the ID direct into the code, otherwise the script would only work in my german AE-version.



  • Mike Overbeck

    July 16, 2014 at 7:30 am

    Just wanted to say that this post saved my bacon. Thanks Dan!
    the findMenuCommandId() and executeCommand() methods are extremely powerful, yet I can’t find any Adobe documentation on them (Oh Adobe..)
    Here’s an interesting related thread over at AE Enhancers. Some of the info may be different since CS3.

  • Xavier Gomez

    July 16, 2014 at 11:01 am

    Coincidence, David Torno very recently made a much more exhaustive list. See this thread:

    Edit: concerning layer styles, it is a pity they don’t work like Text Animator Properties, or shape stroke dashes: properties are always there, adding a property reveals it, removing a property hides it, etc: A lot simpler.


We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy