Hi There,
I'm trying to do something relatively simple, but am having trouble figuring out why it's not working. I want a script that scales a text layer to the correct size so that it fits the extents of its parent comp. I have found a couple of resources that do this, but I think these scripts assume that AE is running with its GUI. In my case, I'm running afterfx.exe from a batch script with the -noui switch. So, when running AE with the -noui switch, it seems that using the app.executeCommand() function doesn't seem to work right. Here are the threads I found for handling exactly what I want, but that both incorporate the app.executeCommand() method:
http://www.aenhancers.com/viewtopic.php?f=8&t=150&start=45
and
http://aenhancers.com/viewtopic.php?f=8&t=150&start=60
Does anybody have any other suggestions for writing a script that fits a text layer to size, or are these the only alternatives out there?
Thank you for your time and help!
You don’t need to use app.executeCommand() for that any more. Something like this should work:
{
var myComp = app.project.activeItem;
var myLayer = myComp.layer(1);
var myRect = myLayer.sourceRectAtTime(0,false);
var myScale = myLayer.property("Scale").value;
var myNewScale = [myScale[0]myComp.width/myRect.width,myScale[1]myComp.height/myRect.height];
myLayer.property("Scale").setValue(myNewScale);
}
Dan
Thank you Dan for that code, it helped tremendously. Is there any way to ensure that the X & Y values of the scale are locked in proportion to one another. My apologies for not being clear in my initial post: I want to fit the text layer to the extents of its parent comp while ensuring its width:height proportions stay intact.
North America
Europe, Middle East and Africa
Asia Pacific