ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Error : Undefined, it's not an object

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Renaud Lionnet
Error : Undefined, it's not an object
on Aug 13, 2018 at 6:58:09 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 &lt; 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 &lt;= 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 &lt; mySelectedLayers.length; i++){
mySelectedLayers[i].selected = true;
}

//jetboots_2

for (var i = 1; i &lt;= 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 &lt; 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();
}


Return to posts index

Dan Ebberts
Re: Error : Undefined, it's not an object
on Aug 13, 2018 at 7:21:19 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



Return to posts index

Renaud Lionnet
Re: Error : Undefined, it's not an object
on Aug 13, 2018 at 7:46:06 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 ?


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]