Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions What’s wrong with my script to enable layer styles?

  • What’s wrong with my script to enable layer styles?

    Posted by Xinlai Ni on September 15, 2009 at 6:10 pm

    Hi cows:
    I have a simple script to add a comp to a project, add a layer to the comp, then
    I attempted to add the “Inner Glow” layer style to the layer. But it doesn’t work –
    by doesn’t work I mean when you twirl down the layer properties, no layer styles
    were ever created.
    Basically what I wanted to do is to automate the menu action
    Layers > Layer Styles > Inner Glow.

    I opened the extended toolkit and watched the var values, the layerStyles variable
    has ‘enabled’ set to true, but its ‘selected’ is set to false, however I can’t
    do layerStyles.selected = true because
    “Cannot set selecred with this property because the property or a parent property
    is hidden”.

    Any help will be appreciated.
    Thanks
    {
    app.beginUndoGroup(“Test”);
    var proj = app.project;
    var projItems = proj.items;
    var comp = projItems.addComp(“foo”, 200, 200, 1, 5, 30);
    var layer1 = comp.layers.addSolid([0.5, 0, 0], “solid”, 200, 200, 1);
    var layerStyles = layer1.property(“Layer Styles”);
    var innerGlow = layerStyles.property(“Inner Glow”);
    alert(innerGlow.enabled);
    app.endUndoGroup();
    }

    Lloyd Alvarez replied 16 years, 4 months ago 3 Members · 3 Replies
  • 3 Replies
  • Lloyd Alvarez

    November 2, 2009 at 11:48 pm

    You need to add the property first using the PropertyGroup addProperty() method

    -Lloyd

    app.project.item(index).layer(index).propertyGroupSpec.addProperty(name)

    https://aescripts.com

  • Tim Andrews

    January 17, 2010 at 12:41 pm

    Although Lloyd’s reply is undoubtably correct, I still don’t understand how to implement “propertyGroupSpec.addProperty(name)”.
    I also fail to understand the Scripting Guide’s explanation of PropertyGroup.

    Although I want to enable ‘Glow’ (as the original poster had wanted), I am assuming the same concepts apply to, for example, setting the type of Light (Spot, Ambient etc) after adding a light using “.addLight”.

    I have searched widely for online explanations or scripts, but even terms like “propertyGroupSpec” only lead me back to the scipting guide.

    Can anyone point me to a page? Or provide some demonstration code.

    Many thanks.

  • Lloyd Alvarez

    January 17, 2010 at 2:12 pm

    Hi Tim,

    Unfortunately, in its current implementation, you can’t set a light type through scripting. If you’d like to understand more about scripting I am currently teaching a scripting course. You can find out more about it by going to aescripts

    -Lloyd

    https://aescripts.com

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