Creative Communities of the World Forums

The peer to peer support community for media production professionals.

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?

  • Mattias Svendsen

    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

  • Mattias Svendsen

    September 23, 2011 at 1:53 pm

    Syntax:
    shapeLayer1(“Effects”).addProperty(“Grow Bounds”);
    Works

    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.

    Dan

  • 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.

    https://forums.creativecow.net/thread/227/13825#13829
    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_1.property("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:

    myTextLayer.property(“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.

    myTextLayer.property(“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.

    Jürgen

  • 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.openInViewer();
    myComp.layer(1).selected = true;
    app.executeCommand(app.findMenuCommandId("Color Overlay"));
    }
    }

    Dan

  • 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.

    app.executeCommand(9006);

    br
    Jürgen

  • 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.
    https://aenhancers.com/viewtopic.php?f=8&t=889

  • Xavier Gomez

    July 16, 2014 at 11:01 am

    Coincidence, David Torno very recently made a much more exhaustive list. See this thread: https://forums.adobe.com/message/6541252#6541252

    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.

    Xavier

Viewing 1 - 10 of 10 posts

Log in to reply.

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