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:
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:
but I just get syntax errors.
I've also tried this way of doing things:
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.
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...
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.
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...
Hi Thomas, How did you convert the binary from the ffx file to include as string in the jsx? Thanx in advance, Rogier
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
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");
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.