ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Help with a script TONIGHT PLEASE

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Adam forbes
Help with a script TONIGHT PLEASE
on Nov 12, 2009 at 6:58:24 am

I need some help fast.

I have multiple projects and thousands of layers so I need a script that will add this expression to every anchor point and every position of a layer:

tempx = value[0];
tempy = value[1];

tempxwhole = Math.round(tempx);
tempywhole = Math.round(tempy);
[tempxwhole, tempywhole]


It's a simple expression to round the position to the nearest integer which in turn makes the illustrator file appear more clear.

What I need is a script that will apply that expression to all layers selected:

I NEED it ASAP!

Thanks

tempx = value[0];
tempy = value[1];

tempxwhole = Math.round(tempx);
tempywhole = Math.round(tempy);
[tempxwhole, tempywhole]


Return to posts index

Dan Ebberts
Re: Help with a script TONIGHT PLEASE
on Nov 12, 2009 at 4:15:04 pm

Try this:

{
var expr = 'tempx = value[0];\r' +
'tempy = value[1];\r' +
'tempxwhole = Math.round(tempx);\r' +
'tempywhole = Math.round(tempy);\r' +
'[tempxwhole, tempywhole]';

var myComp = app.project.activeItem;
var myLayer;
for (var i = 1; i <= myComp.numLayers; i++){
myLayer = myComp.layer(i);
try{
myLayer.property("anchorPoint").expression = expr;
}catch (err){
}
myLayer.property("position").expression = expr;
}
}


Dan



Return to posts index

Adam forbes
Re: Help with a script TONIGHT PLEASE
on Nov 12, 2009 at 4:28:35 pm

Dan,

That's awesome thanks so much. It doesn't seem to work for the WHOLE PROJECT. Is there a way to get it to go through every comp in the project instead of just the one I'm in?


Thanks,

Adam


Return to posts index


Dan Ebberts
Re: Help with a script TONIGHT PLEASE
on Nov 12, 2009 at 5:39:18 pm

{
var expr = 'tempx = value[0];\r' +
'tempy = value[1];\r' +
'tempxwhole = Math.round(tempx);\r' +
'tempywhole = Math.round(tempy);\r' +
'[tempxwhole, tempywhole]';

var myComp;
var myLayer;
for (var j = 1; j <= app.project.numItems; j ++){
myComp = app.project.item(j);
if (myComp instanceof CompItem){
for (var i = 1; i <= myComp.numLayers; i++){
myLayer = myComp.layer(i);
try{
myLayer.property("anchorPoint").expression = expr;
}catch (err){
}
myLayer.property("position").expression = expr;
}
}
}
}



Dan



Return to posts index

Adam forbes
Re: Help with a script TONIGHT PLEASE
on Nov 13, 2009 at 11:27:32 am

Dan,

That worked great for a while, then it seems to really get tripped up by hidden layers.

It says Unable to execute scrpt at line 19. After Effects error. Can not "set Expression" with this property, because the proptery or a parent property is hidden.

any ideas?

Thanks,
Adam


Return to posts index

Dan Ebberts
Re: Help with a script TONIGHT PLEASE
on Nov 13, 2009 at 5:40:17 pm

That's strange. See if this helps:

{
var expr = 'tempx = value[0];\r' +
'tempy = value[1];\r' +
'tempxwhole = Math.round(tempx);\r' +
'tempywhole = Math.round(tempy);\r' +
'[tempxwhole, tempywhole]';

var myComp;
var myLayer;
var isHidden;
var isLocked;
for (var j = 1; j <= app.project.numItems; j ++){
myComp = app.project.item(j);
if (myComp instanceof CompItem){
for (var i = 1; i <= myComp.numLayers; i++){
myLayer = myComp.layer(i);
isLocked = myLayer.locked;
myLayer.locked = false;
isHidden = myLayer.hidden;
myLayer.hidden = false;
try{
myLayer.property("anchorPoint").expression = expr;
}catch (err){
}
myLayer.property("position").expression = expr;
myLayer.locked = isLocked;
myLayer.hidden = isHidden;
}
}
}
}


Dan



Return to posts index

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