-
Bulk convert expressions (source text & scale) into keyframes
Hi there,
I generate 100+ Comps from a spreadsheet (https://aescripts.com/compsfromspreadsheet/ – great script, works like a charm) and need to convert an rather heavy expression afterwards to save time while rendering.
I have already found a solution to a very similar problem here in this forum –> https://forums.creativecow.net/thread/227/13039#13041
I tried do edit the script to my needs, but I doesn’t convert the expressions in the selected comps.
var items = app.project.items;
var selectedComps = new Array();function convertToKeyframes(theProperty){
if (theProperty.canSetExpression && theProperty.expressionEnabled){
theProperty.selected = true;
app.executeCommand(app.findMenuCommandId("Convert Expression to Keyframes"));
theProperty.selected = false;
}
}for (var i = 1; i <= items.length; i++) {
if ((items[i] instanceof CompItem) && items[i].selected) {
selectedComps[i] = items[i];
}
}for (var i = 1; i <= selectedComps.length; i++) {
var comp = selectedComps[i];
if (!comp) continue;var layer = comp.layer(2);
var prop = layer.property("scale");
convertToKeyframes(prop);layer = comp.layer(1);
prop = layer.property("sourceText");
convertToKeyframes(prop);}
What am I doing?
As said, I have 100+ Comps I select in the project panel. Inside each are two text-layers. One with an expression for source code and one with an expression in the scale property.I use this approach (https://motionboutique.com/text-bounds-expresssion-580/) to get the bounding box of the text in layer 2. This is the first expression to be converted. (the script is inside the source text)
The second layer is also a text layer, it got its text from the spreadsheet. It uses the result from layer 1 in the scale expression to make sure, the size of the textbox doesn’t exceed the “maxwidth” I defined.I’m rather useless with code and had help from our programmer, but he doesn’t know anything about AE. He used the ExtendedToolKit to debug and everything we checked had the expected value/outcome. Only there were no expressions converted to keyframes.
Now I am hoping one of you guys could help me find out why, and maybe even fix it.
regards,
Joerg