FORUMS: list search recent posts

Accessing a composition by name

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mark Davis
Accessing a composition by name
on Nov 23, 2014 at 7:23:05 am

I'm trying to create a script that takes a composition named "TIMECODE" and drops it into new composition.

I have managed to create the additional composition and add some footage but I don't know how to access the "TIMECODE" comp by name and add it to the new composition.

I know how to add it by item index number, but not by name. I can't use the item index number because that will vary across projects.

Can someone point me in the right direction please?


Return to posts index

Dan Ebberts
Re: Accessing a composition by name
on Nov 23, 2014 at 4:31:31 pm

You can't access items directly by name, you have to do something like this:


var myCompName = "TIMECODE";
var myComp = null;
for (var i = 1; i <= app.project.numItems; i ++){
if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name == myCompName)){
myComp = app.project.item(i);
break;
}
}
if (myComp == null){
alert("no luck");
}else{
alert ("got it");
}



Dan



Return to posts index

Mark Davis
Re: Accessing a composition by name
on Nov 23, 2014 at 5:06:51 pm

Thank you very much Dan.

I actually thought about doing what you described as a workaround... although it would have taken me some time to get it right (I'm very new at this - it's the first script I've attempted).

It does seem odd that you can't access by name though. You can access layers by name, can't you? And can't you also access Comps by name through Expressions? I could've sworn I've done this in the past.

Thanks again for the code. You saved me much frustration.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]