Page 1 of 1
Item : by name ?
Posted: August 2nd, 2007, 3:23 am
by golgo
Hello there, first post for me
The only way to manipulate an Item seems to call it by its index, that represents his alphabetic position in all the project's items, right ???
Is there a way to call an item (a comp for exemple) by it's name, like for a layer ?
The use of item index is not fair, like when you import a new item, the rank and so the index changes...
thanx for your lights !
Posted: August 2nd, 2007, 9:01 am
by Atomic
You can reference by name, like so...
Code: Select all
var myComp = app.project.activeItem; //NOTE comp must be selected in the project window.
var AudioAmplitudeLayer = myComp.layer("Audio Amplitude");
Audio Amplitude is the name of a layer in my comp.
Now you can refference properties of the layer like so...
Posted: August 2nd, 2007, 9:09 am
by Paul Tuersley
I think Golgo was asking if you could reference a comp by name, in the same way as you can with a layer. I think the only way is to create a loop that goes through all the items, checking for the correct name. Not so bad really.
Posted: August 2nd, 2007, 9:19 am
by Atomic
So,
Does app.project have a count?
Posted: August 2nd, 2007, 11:18 am
by Dan Ebberts
app.project.numItems
Dan
Posted: August 3rd, 2007, 5:35 am
by Atomic
So I guess to scan the project window you could...
Code: Select all
n = app.project.numItems;
for (m=1; m<n; m++;)
{
if (app.project.item(m).name =="Label I am Searching For")
{
//I have found an item in the project window by name.
}
}
Posted: August 3rd, 2007, 4:11 pm
by nab
Index starts at 1 (not 0) for project items.
Posted: August 9th, 2007, 7:05 am
by golgo
Atomic wrote:So I guess to scan the project window you could...
Code: Select all
n = app.project.numItems;
for (m=1; m<n; m++;)
{
if (app.project.item(m).name =="Label I am Searching For")
{
//I have found an item in the project window by name.
}
}
Ok, that works fine. But my goal is to select a comp, so how can I do it ? (activeItem is read only)
Thanx !
Posted: August 9th, 2007, 3:04 pm
by nab
m <
= n , unless you want to skip the last item !
when you have retrieved the item (in a variable), do whatever you want with it (add layers, change settings...)
the scripting guide is a good way to start

Posted: August 10th, 2007, 12:46 am
by )orgen
maybe I don't fully understand the question, but you can at least reference a layer in a specific comp like this:
amp=comp("intro").layer("control").effect("amplitude")("Slider");