Bulk convert expressions into keyframes
by Satya Meka
on
May 25, 2009 at 9:22:44 pm
Hello,
I have a project with more than 200 layers with a lot of expressions for various transform properties. Is there a way I could convert all the expressions to keyframes at once? (atleast with a script/select all animated properties at a time)
Re: Bulk convert expressions into keyframes by Dan Ebberts on May 26, 2009 at 12:11:32 am
This should get you started. It will convert position, anchorPoint, roation, scale, and opacity expressions to keyframes for each layer in the active comp (if the layer has those properties):
{
function convertToKeyframes(theProperty){
if (theProperty.canSetExpression && theProperty.expressionEnabled){
theProperty.selected = true;
app.executeCommand(app.findMenuCommandId("Convert Expression to Keyframes"));
theProperty.selected = false;
}
}
var myComp = app.project.activeItem;
if (myComp && myComp instanceof CompItem){
var myLayer;
var myProperty;
app.beginUndoGroup("convert expressions");
for (var i = 1; i <= myComp.numLayers; i++){
myLayer = myComp.layer(i);
try{
myProperty = myLayer.property("position");
convertToKeyframes(myProperty);
}catch(err){
}
try{
myProperty = myLayer.property("anchorPoint");
convertToKeyframes(myProperty);
}catch(err){
}
try{
myProperty = myLayer.property("rotation");
convertToKeyframes(myProperty);
}catch(err){
}
try{
myProperty = myLayer.property("scale");
convertToKeyframes(myProperty);
}catch(err){
}
try{
myProperty = myLayer.property("opacity");
convertToKeyframes(myProperty);
}catch(err){
}
}
app.endUndoGroup();
}