Skip to main content
JamesBerkheimer
Participating Frequently
March 6, 2015
Answered

How to get comp height and width.

  • March 6, 2015
  • 1 reply
  • 7972 views

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

This topic has been closed for replies.
Correct answer Dan Ebberts

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

1 reply

Dan Ebberts
Community Expert
Community Expert
March 6, 2015

Did you try  myComp.width and myComp.height?

Dan

JamesBerkheimer
Participating Frequently
March 7, 2015

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

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
March 7, 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