Copy link to clipboard
Copied
Hello all,
I have several layers and I want to apply a random animation preset to each layer through a script.
I know how to apply an effect, for eg. [somelayer].property("Effects").addProperty("Block Dissolve"),
but how to apply a whole animation preset (eg. Block Dissolve - digital or Card Wipe - 3D pixelstorm).
Thanks!
Once you have the file path to the preset, you can do it like this:
myLayer.applyPreset(File(myPresetPath));
Dan
Copy link to clipboard
Copied
Once you have the file path to the preset, you can do it like this:
myLayer.applyPreset(File(myPresetPath));
Dan
Copy link to clipboard
Copied
Thank you for such a fast answer!!!
P.S.
It works but only on a currently selected layer. If none of the layers are selected, AE simply creates a new Solid layer and applies preset on it:
var activeComp = app.project.activeItem;
var compLayers = activeComp.layers;
var preset = File('C:\\Program\ Files\\Adobe\\Adobe\ After\ Effects\ CS5.5\\Support\ Files\\Presets\\Transitions\ -\ Movement\\Card\ Wipe\ -\ 2D\ fractured.ffx')
for (var i = 1; i <=compLayers.length; i++){
compLayers.applyPreset(preset);
}
Copy link to clipboard
Copied
Well, it looks like I have to select layer and then apply preset:
var activeComp = app.project.activeItem;
var compLayers = activeComp.layers;
var preset = File('C:\\Program\ Files\\Adobe\\Adobe\ After\ Effects\ CS5.5\\Support\ Files\\Presets\\Transitions\ -\ Movement\\Card\ Wipe\ -\ 2D\ fractured.ffx');
for (var i = 1; i <=compLayers.length; i++){
compLayers.selected = true;
compLayers.applyPreset(preset);
compLayers.selected = false;
}
Copy link to clipboard
Copied
Yes, that's true--sorry I forgot to mention it.
Dan
Copy link to clipboard
Copied
I'm trying to apply this but cannot seem to get it working.
var preset = File('/Users/adamforbeslocal/Documents/Adobe/After Effects CC 2014/User Presets/Asterisk.ffx')
var layerName = "Asterisk";
var newPosition = [100,100];
var newScale = [00,100];
var myLayer = app.project.activeItem.layer(layerName);
myLayer.property("Position").setValue(newPosition);
myLayer.property("Scale").setValue(newScale);
myLayer.applyPreset(preset);
I have a layer names "Asterisk" I'm trying to apply an animation preset to it. Right now I just have scale in position in there for testing purposes.
I want to make sure this works when even other layers are selected... I want it to find the specific layer asterisk in my project and apply a preset....
Right now it adjust the position of the asterisk layer then the scale, then it creates a new solid and adds the preset to that solid instead of adding it to the asterisk layer.
Can't quite figure it out. Is there a way to get it to add it to only the layer named asterisk, without selecting the layer asterisk?
Thanks
Adam
Copy link to clipboard
Copied
What does the ffx file do? If it makes a shape - preset, AE will make a layer for the shape. . . as opposed to say a blur effect that can be applied to a footage layer.
Copy link to clipboard
Copied
The Preset Animates the scale and the rotation. That's it.
Copy link to clipboard
Copied
If it's important that you not disturb the selection, you can save it, select your asterisk layer and deselect all others, apply the preset, and restore the original selection--like this:
var myComp = app.project.activeItem;
var asteriskLayer;
// save selection
var mySelectedLayers = myComp.selectedLayers;
// find asterisk layer and deselect all others
for (var i = 1; i <= myComp.numLayers; i++){
if (myComp.layer(i).name == "Asterisk"){
asteriskLayer = myComp.layer(i);
asteriskLayer.selected = true;
}else{
myComp.layer(i).selected = false;
}
}
// apply preset
asteriskLayer.applyPreset(File(myPresetPath));
asteriskLayer.selected = false;
// restore original selection
for (var i = 0; i < mySelectedLayers.length; i++){
mySelectedLayers.selected = true;
}
Dan
Find more inspiration, events, and resources on the new Adobe Community
Explore Now