Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scripting: Issues with effects and layer order …

  • Scripting: Issues with effects and layer order …

    Posted by Markus Feder on July 29, 2010 at 3:18 pm

    Hi There,

    I am working on a script to help me cut some corners in my workflow. Most of the part
    went pretty smooth by taking a look at how other scripts are done but with some details
    i ran into a couple of problems that i can´t solve on my own.

    Heres an example of what the script does:
    Button gets pressd: Create a new Adjustment Layer, add effects levels, curves and saturation to it. done

    Sounds pretty easy and works fine for the most part.

    Here are the problems i have:
    1. My new Layer is always created on top of the composition. I want it to be above the layer that
    was selected before pressing the button. If no layer is selected its ok for the new Layer to be on top.

    2. I want to share this script with other people so i want to check if the selected effect is really
    available on the machine where the script is runing before creating the layer. Right now if the effect is
    missing the layer is created but its empty (of course).

    3. For some Operations, like the mentioned example with the levels etc. I wan to make the effects panel
    active after creating the layer so i can smoothly start tweeking the effects without manually chaning to the effects control panel.

    If you have any questions or if my explanation is not clear please ask me !

    Many questions I know, but I really hope someone can help me out! Would be great ! Thanks in advance!!

    Markus

    Lloyd Alvarez replied 15 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Markus Feder

    July 30, 2010 at 11:07 am

    Hi there,

    I figured out a solution for the first part …
    In case anyone is interested, here´s my code:

    —————————————————–
    // Selected Composition
    var comp = app.project.activeItem;
    // Selected Layers
    var slctd_layer = comp.selectedLayers;

    // Create new Solid and set Adjustment Layer Flag
    var new_adjustment = comp.layers.addSolid([1,1,1], “Adjustment Layer”, comp.width,comp.height,comp.pixelAspect,comp.duration);
    new_adjustment.adjustmentLayer = true;

    // Check if at least one Layer is Selected
    // if so move the new Layer on top of the selected one
    if ( slctd_layer[0] != null){
    //alert (slctd_layer[0].index);
    new_adjustment.moveBefore(slctd_layer[0]);
    }
    —————————————————–

    But I still can´t figure out how to activate the “Effects Control Panel”. If someone knows what the internal
    aftereffects name is that would help I guess.

    And I still need a way to check if the used effects are available.
    (One workaround I can think of is to let the script do its thing and at the end check if the effect
    was applied or not and then delete the layer again … but that looks not like a good way to me …)

    I still could need some help ….

  • Lloyd Alvarez

    August 2, 2010 at 10:08 pm

    To check if you can apply an effect use the PropertyGroup canAddProperty() method (page 148 of the CS3 scripting guide):

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

    And there’s no way to activate the effects panel through scripting but F3 brings it up quickly 🙂

    -Lloyd

    https://aescripts.com

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