How to set a reference to compositions name instead of index

What type of scripts do you need?

Moderator: byronnash

Post Reply
Andres
Posts: 1
Joined: May 8th, 2012, 7:58 am

I need to work with some variables contained in the first layer of a precomp in order to move some of the in-out points of the in my main comp.

When working with Expressions I was able to reference the comp's name directly using [comp("comp name")
But the same method doesn't seem to apply for scripting.
And the current item and selected item won't get me where i need to go as I need to get values from many precomps.

This is what I'm trying to to do

Code: Select all

Vid1Dur = comp("Put 1st video here").layer(1).outPoint; //gets precomps 1st layers length by retrieving the outpoint
Thanks everyone. I'm looking forward to learn and help as my skills improve.
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

If you want to find a comp by name, you have to loop through the project items, like this:

Code: Select all

var theComp = null;
var theName = "Put 1st video here";
for (var i = 1; i <= app.project.numItems; i++){
	if (app.project.item(i) instanceof CompItem && app.project.item(i).name == theName){
		theComp = app.project.item(i);
		break;
	}
}

// test for theComp == null
Dan
Post Reply