ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

[extendScript] Select a project item without using its index ?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Charlie Leroy[extendScript] Select a project item without using its index ?
by on Mar 12, 2015 at 7:15:36 pm

Hello hello,

this sounds like a stupid questions,
but I can not find a way to select an item in the Project panel using something else than the (index).

the main issue with index is that it changed depending of the position of the item in the panel. and I am creating a lot of new comp and folder dynamically so depending of the name of the created item, all the other items are changing their ID.

Is there a way to select an item using either the name or the id number(wich would be the best I guess).

sorry for the noob question but i am stuck and the scripting guide is not helping :s

thanks!


Return to posts index


Walter SoykaRe: [extendScript] Select a project item without using its index ?
by on Mar 13, 2015 at 2:06:49 pm

You can create an object to hold a specific comp, like this:

compA = app.project.items.addComp("First comp created by script", 1920, 1080, 1, 10, 29.97);
compB = app.project.items.addComp("Second comp created by script", 1920, 1080, 1, 10, 29.97);
alert(compB.name);
alert(compA.name);


Then you can refer to the object in your code instead of the item within a collection.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Charlie LeroyRe: [extendScript] Select a project item without using its index ?
by on Mar 13, 2015 at 4:09:31 pm

Hello Walter,
thanks a lot, that is working perfectly!
I am learning to script on the go and this notion is going to ease my life :)
thanks!


Return to posts index


Fabio ApelbaumRe: [extendScript] Select a project item without using its index ?
by on Apr 22, 2015 at 6:20:42 pm

Hi Walter, I saw your response to this thread, pretty cool. Now, let me ask you.... I do have a collection of items required to run my script.

I have in my script an if/else that stays if the file name of the current project is equals to the file name required to open, then, dont open it again and move on. But where I am having problems is that sometimes the producers imports the actual project into a new project with a different file name... so I dont know how to tell the script that if it finds element "x"within the project collection.... is because the original project has been imported... so do not open the project again and just move on with the rest of the script....

any ideas?

thanks!


Return to posts index

Walter SoykaRe: [extendScript] Select a project item without using its index ?
by on Apr 22, 2015 at 6:35:28 pm

Rather than testing the filename, why don't you iterate through all the items in the project, looking for the ones you expect to see. If they are all there, proceed with the script; if they are not, alert the user to which elements are missing and suggesting they re-import the base project.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Fabio ApelbaumRe: [extendScript] Select a project item without using its index ?
by on Apr 22, 2015 at 6:40:19 pm

sounds like an awesome approach. I believe it will all have to start with a for loop that reads all the files in the project, right?.. could you please tell me how should I write it, any tips will be highly appreciated, Im still learning on the go.


Return to posts index


Walter SoykaRe: [extendScript] Select a project item without using its index ?
by on Apr 23, 2015 at 1:31:24 pm

Fabio, yes, I think you're on the right track. I'd loop through each item in app.project.items, and check it for whatever identifying characteristics you have in mind -- perhaps filename for FootageItem elements.

This sample code will step through every item in a project, and open an alert window showing the file name of any pieces of footage:

for (i=1; i<=app.project.items.length; i++) {
if (app.project.item(i) instanceof FootageItem) {
alert(app.project.item(i).file.name);
}
}


Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

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