Copy link to clipboard
Copied
Hi, I'm writing a script that sends my AE comps to a render farm. I need to grab the frame size (height and width) of the comp. But I'm having trouble finding the method to do so. Is this possible via javascript?
Thanks
myComp would be a reference to your comp object. You might get it from the activeItem if your comp is open and selected:
var myComp = app.project.activeItem;
If not, you'll have to loop through the project items until you find a comp item with the name of the comp you're looking for (not tested, but should be close):
var myCompName = "Main Comp";
var myComp = null;
for (var i = 1; i <= app.project.numItems; i++){
if ((app.project.item(i).name == myCompName) && (app.project.item(i) instanceof Comp
...Copy link to clipboard
Copied
Did you try myComp.width and myComp.height?
Dan
Copy link to clipboard
Copied
so would myComp be replaced with my comp name or is that a method itself?
Copy link to clipboard
Copied
myComp would be a reference to your comp object. You might get it from the activeItem if your comp is open and selected:
var myComp = app.project.activeItem;
If not, you'll have to loop through the project items until you find a comp item with the name of the comp you're looking for (not tested, but should be close):
var myCompName = "Main Comp";
var myComp = null;
for (var i = 1; i <= app.project.numItems; i++){
if ((app.project.item(i).name == myCompName) && (app.project.item(i) instanceof CompItem)){
myComp = app.project.item(i);
}
}
if (myComp != null){
var w = myComp.width;
var h = myComp.height;
}else{
alert("Can't find comp " + myCompName);
}
Dan
Copy link to clipboard
Copied
Hi Dan, thanks a ton for this! I've been away for a few days so I'm finally getting to this, but your code me exactly what I want. Do you happen to know what other items I can grab from myComp or maybe link me to some relevant documentation? I'm also looking for the file output format but I'm thinking this might be coming from elsewhere. Maybe the outputModel?
Thanks again,
James
Copy link to clipboard
Copied
A great way to see what properties and methods are available for an Object is to use the reflect object. So....
alert(myComp.reflect.properties); //Would show properties (returns an Array) that this object has.
alert(myComp.reflect.methods); //Would show methods (returns an Array) that this object has.
Copy link to clipboard
Copied
Thanks David, these were informative.
Copy link to clipboard
Copied
In the After Effects Scripting Guide, look up Item object, AVItem object, and CompItem object to see all the attributes of a comp. I'm not sure what you mean about output format as it relates to a comp--you are probably looking for the OutputModule object. But get the scripting guide, it will help a lot.
Dan
Copy link to clipboard
Copied
I'm looking for the file type. Like PNG, JPG, or EXR....etc. But I'll check out the scripting guide.
Thanks!
Copy link to clipboard
Copied
A comp won't have an associated file type. If you create the comp by dragging a footage item onto the Create a New Composition button, the comp name will have the file extension. Also, a layer in the comp may have a source with a file extension. If you put the comp in the render queue, the output file will have a file extension. It's not exactly clear what you're after.
Dan
Copy link to clipboard
Copied
OK, I apologize for the miscommunications. I'm not really an After Effects user and I'm being asked to incorporate it into our render farm. Frankly, if I can get the outputfile name that should include the file extension in it correct? If so then I can parse the file name in order to get the extension name. But I noticed in the comp there is a section called the "Output Module"...which says my output is going to be a PNG Sequence.
When I click on this it opens up a window dialog. In there I can change the "format" type of the output file sequence. So I assumed that I might have access to the "Format" type the same way I was able to get the "width" and "height". I hope this makes more sense.
Copy link to clipboard
Copied
The output file name is associated with the render queue item, not the comp. It doesn't exist for a new comp. It will exist when the comp is added to the render queue, and may still exist after the comp is rendered, but not necessarily because render queue items can be deleted without affecting the comp.
Dan
Copy link to clipboard
Copied
Thanks Dan, with your help I was able to gather all the information I needed and also learn a bit more about scripting in After Effects.
Cheers!
James
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more