Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Error : Undefined, it’s not an object

  • Error : Undefined, it’s not an object

    Posted by Renaud Lionnet on August 13, 2018 at 6:58 pm

    Hello everyone! (My apologies in advance for my English )

    I’m new to After Effect scripting, with you’re forum i have been capable of making a semblance of script that work, but I’m currently having a problem.

    I have a script that duplicate layer, rename it and depending on the name adding an animation preset. The script working well , but I don’t know why after a certain number of utilisation it doesn’t work anymore, there is no change in the script just doesn’t fully working anymore it’s stop after the duplication and rename of the layer.

    The Error Message a receive it’s :

    “Line 34 : undefined, it’s not an object”

    Same problem with different Computer and After effects version work at the start and after always same issue.

    Thanks ☺

    {
    // create an undo group
    app.beginUndoGroup("AddEffect");

    //variables
    var myComp = app.project.activeItem;
    var mySelectedLayers = myComp.selectedLayers;
    var myName = myComp.name;
    var thePreset1 = File("./Preset_FFX/BURST_PASS_1.ffx");
    var thePreset2 = File("./Preset_FFX/BURST_PASS_2.ffx");
    var effectLayer;
    var newComp;
    var days = ["Burst_1","Burst_2"];

    //duplicate

    for (var i = 0; i < days.length; i++){
    var curLayer = myComp.selectedLayers[0];
    newComp = curLayer.duplicate();
    newComp.name = myName.substr(0,myName.length-30) + days[i];
    }

    //jetboots_1

    for (var i = 1; i <= myComp.numLayers; i++){
    if (myComp.layer(i).name == "Burst_1"){
    effectLayer = myComp.layer(i);
    effectLayer.selected = true;
    }else{
    myComp.layer(i).selected = false;
    }
    }
    effectLayer.applyPreset(thePreset1);
    effectLayer.blendingMode = BlendingMode.ADD;
    effectLayer.selected = false;
    for (var i = 0; i < mySelectedLayers.length; i++){
    mySelectedLayers[i].selected = true;
    }

    //jetboots_2

    for (var i = 1; i <= myComp.numLayers; i++){
    if (myComp.layer(i).name == "Burst_2"){
    effectLayer = myComp.layer(i);
    effectLayer.selected = true;
    }else{
    myComp.layer(i).selected = false;
    }
    }
    effectLayer.applyPreset(thePreset2);
    effectLayer.selected = false;
    for (var i = 0; i < mySelectedLayers.length; i++){
    mySelectedLayers[i].selected = true;
    }
    // Supprimer le layer en trop

    try {
    if(!curLayer.visisible) curLayer.visible = true;
    if(curLayer.locked) curLayer.locked = false;
    curLayer.remove();
    } catch (e) {}

    app.endUndoGroup();
    }

    Renaud Lionnet replied 7 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    August 13, 2018 at 7:21 pm

    My guess would be that you’re getting into a situation where effectLayer hasn’t been defined. Maybe no comp is selected, or the comp doesn’t have the right name.

    Dan

  • Renaud Lionnet

    August 13, 2018 at 7:46 pm

    Yes ! thanks ☺ when i apply the effect on a Layer that’s in many precomp it’s not working, but if it’s just at the base of the project it work.

    But do you now know making this script work in any circumstance ?

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