ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Changing the off set of a layer position in a script

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Coby GrossChanging the off set of a layer position in a script
by on May 21, 2013 at 11:27:40 pm

So I have a script that needs to change the position of a layer but I keep getting this error: invalid numeric result(divide by zero?)

here is the line:
myComp.layer(2).transform.position + [5,2]

Im positive there is a layer at index 2 and I'm positive myComp is set to the active comp. Any ideas as to why I would get this?


Return to posts index

Ridley WalkerRe: Changing the off set of a layer position in a script
by on May 21, 2013 at 11:33:10 pm

There's nothing inherently wrong with the expression as long as the variable myComp refers to a Composition and the it has a layer 2.

What confuses me is the divide by zero error when there is no division operator in the expression. Is this the entire script or just the line identified in the error message?


Return to posts index

Coby GrossRe: Changing the off set of a layer position in a script
by on May 21, 2013 at 11:49:19 pm

This is just the line of error. There is no division in the entire script though.


Return to posts index


Ridley WalkerRe: Changing the off set of a layer position in a script
by on May 21, 2013 at 11:58:06 pm

[Coby Gross] "This is just the line of error. There is no division in the entire script though.

"


It would be helpful to see the entire expression.


Return to posts index

Coby GrossRe: Changing the off set of a layer position in a script
by on May 22, 2013 at 12:02:24 am

Ah sure thing, here is the entire While Loop it is in, nothing outside of it should affect it:


var myComp;
//Read lins of text. Create a new comp and text layer for each line
var text;

while(!myFile.eof)
{
text = myFile.readln();
if(text == "") text = "r";

myComp = app.project.items.addComp(text,compW,compH,1,compL,compRate);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Set the text layer
var tl = myComp.layers.addText(text);
var tltxt = tl.property("ADBE Text Properties").property("ADBE Text Document");
var txt = tltxt.value;
txt.font = "Verdana";
tltxt.setValue(txt);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var precomp = myComp.layers;

precomp.precompose([1],text + "precomp");
myComp.layer(1).duplicate();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Add Fill Effect
layerProperties = myComp.layer(2);
layerProperties.Effects.addProperty("Fill");
layerProperties.Effects.property("Fill").property("Color").setValue([0,0,0]);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Add the offset

//layerProperties.transform.position + [5,2];
myComp.layer(1).transform.position + [5,2];


}


Return to posts index

Ridley WalkerRe: Changing the off set of a layer position in a script
by on May 22, 2013 at 4:33:41 am

I'm not seeing anything obvious here. Initially I thought this was an expression but now see you have a script reading an external text file and generating new layers.

You may have better luck posting your question on the Expressions forum, Dan Ebberts, a scripting master replies to many posts there.

http://forums.creativecow.net/adobe_after_effects_expressions


Return to posts index


Coby GrossRe: Changing the off set of a layer position in a script
by on May 22, 2013 at 5:42:45 am

Okay, I will. Thank you for the link.


Return to posts index

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