Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to apply animation preset to a selected or all layers through a script?

Community Beginner ,
Oct 07, 2015 Oct 07, 2015

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!

TOPICS
Scripting
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 07, 2015 Oct 07, 2015

Once you have the file path to the preset, you can do it like this:

myLayer.applyPreset(File(myPresetPath));

Dan

Translate
Community Expert ,
Oct 07, 2015 Oct 07, 2015

Once you have the file path to the preset, you can do it like this:

myLayer.applyPreset(File(myPresetPath));

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 07, 2015 Oct 07, 2015

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 07, 2015 Oct 07, 2015

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 07, 2015 Oct 07, 2015

Yes, that's true--sorry I forgot to mention it.

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 18, 2016 Apr 18, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 19, 2016 Apr 19, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2016 Apr 29, 2016

The Preset Animates the scale and the rotation.  That's it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 29, 2016 Apr 29, 2016
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines