Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesTrainingCreative Cloud DebateFAQ

After Effects Script - loop through selected items

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Stephen KennedyAfter Effects Script - loop through selected items
by on Jan 21, 2012 at 9:15:26 am

Hi,

I've just started trying to write my first script for AE. Have managed to cobble together a script that executes fine for a single selected item, but I can't seem to find a way to build a for loop to execute the script for every selected item. The script simply takes the item (which will be an image sequence), places it in a new 1920x1080 comp, adds a Transform effect and rescales to 150%. Can anyone help me build a loop for this?
Here is the code:

var mySelection = app.project.activeItem
var myComp = app.project.items.addComp(mySelection.name, 1920, 1080, 1, mySelection.duration, 24)
var myLayer = myComp.layers.add(mySelection)
var myTransform = myLayer.Effects.addProperty("Transform")
myTransform.property(4).setValue(150)


Return to posts index
Reply   Like  


Dan EbbertsRe: After Effects Script - loop through selected items
by on Jan 21, 2012 at 9:41:24 am

This should work:


var mySelectedItems = [];
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i).selected)
mySelectedItems[mySelectedItems.length] = app.project.item(i);
}
for (var i = 0; i < mySelectedItems.length; i++){
var mySelection = mySelectedItems[i];
var myComp = app.project.items.addComp(mySelection.name, 1920, 1080, 1, mySelection.duration, 24);
var myLayer = myComp.layers.add(mySelection);
var myTransform = myLayer.Effects.addProperty("Transform");
myTransform.property(4).setValue(150);
}



Dan



Return to posts index
Reply   Like  
+1

Stephen KennedyRe: After Effects Script - loop through selected items
by on Feb 1, 2012 at 12:20:35 pm

This works perfectly, thank you so much for your help.
S


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSMAGAZINESTOCKYARDVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2013 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]