FORUMS: list search recent posts

Adding label to specific item EXTENDSCRIPT

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rainier Raydán
Adding label to specific item EXTENDSCRIPT
on May 10, 2017 at 8:53:09 pm

Hi!

I`m working in a project at the office and we want to write a script that creates folders. I've already did that with this simple code:

app.project.items.addFolder("RENDER");
app.project.items.addFolder("FOOTAGE");
app.project.items.addFolder("MATERIALES");
app.project.items.addFolder("PRECOMPS");


Then we want to add labels to an specific folder, in this case is the "RENDER" folder. It suppose to change to red and the other stay in yellow.

I've try this:

app.project.items.addFolder("RENDER");
app.project.items.addFolder("FOOTAGE");
app.project.items.addFolder("MATERIALES");
app.project.items.addFolder("PRECOMPS");
app.project.item(4).label= (1)


But I dont want to guess the index of the item, I just want the RENDER folder to turns red. There's a way to add labels to an item named RENDER?

THANKS!


Return to posts index

Dan Ebberts
Re: Adding label to specific item EXTENDSCRIPT
on May 10, 2017 at 9:36:21 pm

The simplest would probably be to save the Render folder in a variable:

var renderFolder = app.project.items.addFolder("RENDER");
app.project.items.addFolder("FOOTAGE");
app.project.items.addFolder("MATERIALES");
app.project.items.addFolder("PRECOMPS");
renderFolder.label= 1;

Alternatively, you could loop through the project items until you find a FolderItem named "RENDER".


Dan



Return to posts index

Rainier Raydán
Re: Adding label to specific item EXTENDSCRIPT
on May 10, 2017 at 9:37:35 pm

I think I solve it with this :

app.project.items.addFolder("# RENDER comps");
app.project.items.addFolder("FOOTAGE");
app.project.items.addFolder("MATERIALES");
app.project.items.addFolder("PRECOMPS");
app.project.items.addFolder("Solids");

var i = 1;

while (i<= app.project.items.length){

var itemX = app.project.item(i);

i = i + 1;
if (itemX.name == "# RENDER comps"){

itemX.label = (1);
}
}


But know I want to add a line that ignores "Solids" folder if the folder already exist.

Can anybody help me?


Return to posts index


Dan Ebberts
Re: Adding label to specific item EXTENDSCRIPT
on May 10, 2017 at 9:54:12 pm

Something like this:


var foundIt = false;
for (var i = 1; i <= app.project.items.length; i++){
if (app.project.item(i) instanceof FolderItem && app.project.item(i).name == "Solids"){
foundIt = true;
break;
}
}
if (! foundIt){
app.project.items.addFolder("Solids");
}



Dan



Return to posts index

Rainier Raydán
Re: Adding label to specific item EXTENDSCRIPT
on May 11, 2017 at 1:28:17 pm

Thanks! Works just fine.


Return to posts index

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