Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to get comp height and width.

New Here ,
Mar 06, 2015 Mar 06, 2015

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

TOPICS
Scripting
8.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 06, 2015 Mar 06, 2015

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

...
Translate
Community Expert ,
Mar 06, 2015 Mar 06, 2015

Did you try  myComp.width and myComp.height?

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 06, 2015 Mar 06, 2015

so would myComp be replaced with my comp name or is that a method itself?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2015 Mar 06, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 11, 2015 Mar 11, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 11, 2015 Mar 11, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 11, 2015 Mar 11, 2015

Thanks David, these were informative.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 11, 2015 Mar 11, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 11, 2015 Mar 11, 2015

I'm looking for the file type.  Like PNG, JPG, or EXR....etc.  But I'll check out the scripting guide.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 11, 2015 Mar 11, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 11, 2015 Mar 11, 2015

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.

afterEffects01.JPG

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.

afterEffects02.JPG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 11, 2015 Mar 11, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 11, 2015 Mar 11, 2015
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines