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

Script for Applying Animation Preset to Layer

New Here ,
Feb 23, 2018 Feb 23, 2018

Copy link to clipboard

Copied

Hello,

I've been trying to make a simple script in AE CC 2018 to create a null object and rename it, then apply an already-created animation preset to it.

The first half works:

var myComp = app.project.activeItem;
var myNull = myComp.layers.addNull(myComp.duration);
myNull.name = "Wipe Duration Control";

However I can't for the life of me figure out how to set up the second half. I tried the following in a separate script as to not mess up the first half:

var myNull2 = app.project.activeItem
myNull2.applyPreset(File("~/Users/Noah/Documents/Adobe/After Effects CC 2018/User Presets/Automated Wipes/Wipe Duration Control.ffx"));

but I just get syntax errors.

I've also tried this way of doing things:

var myNull2 = app.project.activeItem
var presetPath = “Macintosh HD/Users/Noah/Documents/Adobe/After Effects CC 2018/User Presets/Automated Wipes/Wipe Duration Control.ffx”;
Var myPreset = File(presetPath);
myNull2.applyPreset(myPreset);

But still no luck. Does anyone see what I'm doing wrong? This seems like the most rudimentary of scripting functions, so it's frustrating to miss something that must be under my nose.

Thanks!

TOPICS
Scripting

Views

4.1K

Translate

Translate

Report

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

Enthusiast , Feb 24, 2018 Feb 24, 2018

Well the most obvious issue is that the scripting guide explains that applyPreset() is a layer method, so you apply it to a layer not a comp, so...

myNull2.layer(1).applyPreset(myPreset);

Votes

Translate

Translate
Enthusiast ,
Feb 24, 2018 Feb 24, 2018

Copy link to clipboard

Copied

Well the most obvious issue is that the scripting guide explains that applyPreset() is a layer method, so you apply it to a layer not a comp, so...

myNull2.layer(1).applyPreset(myPreset);

Votes

Translate

Translate

Report

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
Enthusiast ,
Feb 24, 2018 Feb 24, 2018

Copy link to clipboard

Copied

Or even:

myNull.applyPreset(myPreset);

I'm not sure why you're using the myNull2 in your example as you already had myComp which was the activeItem then had the null layer as myNull, but I'm sure you can see now that you're trying to apply it with myNull2 which is the active comp and not a layer.

Votes

Translate

Translate

Report

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
Advocate ,
Feb 24, 2018 Feb 24, 2018

Copy link to clipboard

Copied

Also if you feel adventurous, here's an old snippet of mine that does exactly what you are after.rendertom / _Snippets_ / source / After Effects / Apply Pseudo Effect as Animation Preset.jsx — Bitb...

Votes

Translate

Translate

Report

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 ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

Hi Thomas, How did you convert the binary from the ffx file to include as string in the jsx? Thanx in advance, Rogier

Votes

Translate

Translate

Report

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
Advocate ,
Feb 24, 2018 Feb 24, 2018

Copy link to clipboard

Copied

You file paths look really funky to me. Are you sure you are pointing to your file?

To get a path to your file, simples way is to right+click on your file, then click ALT, and somewhere in the middle of the dropdown you'll see Copy "yourFileNameHere" as Pathname

Votes

Translate

Translate

Report

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 ,
Feb 26, 2018 Feb 26, 2018

Copy link to clipboard

Copied

Thanks to both of you I was able to troubleshoot and clean up my code. Here's the final version for anyone stumbling across this later:

var myComp = app.project.activeItem;

var myNull = myComp.layers.addNull(myComp.duration);

myNull.name = "Transition Duration Control";

var thePreset = File("/Users/Noah/Documents/Adobe/After Effects CC 2018/User Presets/Automated Transitions/Dynamic Transition Control.ffx");

myNull.applyPreset(thePreset);

Thanks again!

Votes

Translate

Translate

Report

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 ,
Aug 08, 2020 Aug 08, 2020

Copy link to clipboard

Copied

LATEST

As I recall, one key issue when using applyPreset() is that you want to make sure that the layer you are targeting is the only layer selected. So you may want to loop through and deselect each layer, then select the one you want to apply the preset to.

 

Dan

Votes

Translate

Translate

Report

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