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 !
Item : by name ?
Moderator: Paul Tuersley
You can reference by name, like so...
Audio Amplitude is the name of a layer in my comp.
Now you can refference properties of the layer 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");
Now you can refference properties of the layer like so...
Code: Select all
t=AudioAmplitudeLayer.inPoint;
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
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.
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
app.project.numItems
Dan
Dan
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.
}
}
Last edited by Atomic on August 6th, 2007, 5:58 am, edited 1 time in total.
Index starts at 1 (not 0) for project items.
Ok, that works fine. But my goal is to select a comp, so how can I do it ? (activeItem is read only)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. } }
Thanx !
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
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