I am trying to use the Apply Effect script code from the AE Scripting Guide pdf.
Problem is, for some reason, in the pdf there are weird extra spaces between many of the words & code that should not be there. Being a non-scripter I cannot find/fix the errors that are not obvious. english errors.
Would anyone be kind enough to furnish me with the complete code for a script that would apply an effect (any effect, since I can change that, I do know how to do that!)
thanks!
AE Scripting Guide example script
Moderator: Paul Tuersley
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
Don't have that guide to refer to, but here's some simple ways to apply effects, starting with the most simple:
This applies the "Levels" effect to the 1st layer in the active Comp:
This applies the "Levels" effect to any selected layers
And this prompts you to enter the name of the effect, which it then applies to the selected layers in the active comp
Hope that helps you out.. Also in AE7 you can now apply an Animation Preset through scripting which I have found more useful:
-Lloyd
This applies the "Levels" effect to the 1st layer in the active Comp:
Code: Select all
var myComp = app.project.activeItem;
var myLayer = myComp.layer(1);
myLayer("Effects").addProperty("Levels");
This applies the "Levels" effect to any selected layers
Code: Select all
var myComp = app.project.activeItem;
var selectedLayers = myComp.selectedLayers;
for (var i = 0; i < selectedLayers.length; i++) {
var myLayer = selectedLayers[i];
myLayer("Effects").addProperty("Levels");
}
Code: Select all
var myEffect = "Levels";
myEffect = prompt("What effect would you like to add", myEffect);
var myComp = app.project.activeItem;
var selectedLayers = myComp.selectedLayers;
for (var i = 0; i < selectedLayers.length; i++) {
var myLayer = selectedLayers[i];
myLayer("Effects").addProperty(myEffect);
}
Hope that helps you out.. Also in AE7 you can now apply an Animation Preset through scripting which I have found more useful:
Code: Select all
var myFile = fileGetDialog("Select Animation Preset","");
var myComp = app.project.activeItem;
var selectedLayers = myComp.selectedLayers;
for (var i = 0; i < selectedLayers.length; i++) {
var myLayer = selectedLayers[i];
myLayer.applyPreset(myFile);
}
-Lloyd