Highlighted

Script for Applying Animation Preset to Layer

New Here ,
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!

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

Topics

Scripting

Views

1.3K

Likes

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

Script for Applying Animation Preset to Layer

New Here ,
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!

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

Topics

Scripting

Views

1.3K

Likes

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

Likes

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
Reply
Loading...
Engaged ,
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.

Likes

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
Reply
Loading...
Adobe Community Professional ,
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...

Likes

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
Reply
Loading...
New Here ,
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

Likes

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
Reply
Loading...
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
New Here ,
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!

Likes

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
Reply
Loading...
Guide ,
Aug 08, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...