Activity › Forums › Adobe After Effects › Changing the off set of a layer position in a script
-
Changing the off set of a layer position in a script
Posted by Coby Gross on May 21, 2013 at 11:27 pmSo 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?
Coby Gross replied 13 years, 2 months ago 2 Members · 6 Replies -
6 Replies
-
Ridley Walker
May 21, 2013 at 11:33 pmThere’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?
-
Coby Gross
May 21, 2013 at 11:49 pmThis is just the line of error. There is no division in the entire script though.
-
Ridley Walker
May 21, 2013 at 11:58 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.
-
Coby Gross
May 22, 2013 at 12:02 amAh 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];}
-
Ridley Walker
May 22, 2013 at 4:33 amI’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.
https://forums.creativecow.net/adobe_after_effects_expressions
Reply to this Discussion! Login or Sign Up