launch a preset bug

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
bkan
Posts: 51
Joined: November 6th, 2013, 8:33 am

Hello,
I try to apply preset on text layers selected, but it doesn't work. I can't understand why :

var presetPath = ("C:\Program Files\Adobe\Adobe After Effects CS6\Support Files\Presets\PRESETS PERSOS\NEW MATRUNKS\animTexte3D.ffx");
var myPreset = File(presetPath);
for (var i=0;i<app.project.activeItem.selectedLayers.length;i++){
var calque = app.project.activeItem.selectedLayers;
calque.applyPreset(myPreset);
}

Any idea?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

It worked ok for me. Are you getting any errors? Is the debugger enabled in the prefs?
Maybe the file path is incorrect?

Here's some code you can try:

Code: Select all

var thePreset = File.openDialog("Locate the preset");
$.writeln(thePreset.fsName);
var presetPath = ("C:\Program Files\Adobe\Adobe After Effects CS6\Support Files\Presets\PRESETS PERSOS\NEW MATRUNKS\animTexte3D.ffx");
var myPreset = File(presetPath);
$.writeln(myPreset.exists);
var calque = app.project.activeItem.selectedLayers[0];
calque.applyPreset(myPreset);
Use this to help confirm you've got the file path right. It will also tell you if the file exists. Note that I've removed the for loop. Although you need to specify a layer to apply the preset to, it will apply it to all selected layers, exactly the same behaviour as if you did it manually.

Paul
bkan
Posts: 51
Joined: November 6th, 2013, 8:33 am

Thank you again, Paul!
But it's really strange, because on my computer, I locate the prest and clic OK, but then after effects tell me "Line 7 Execution halted" (for the line "calque.applyPreset(myPreset);"). I had the same error in my previous code ; strange, isn't it?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

That code doesn't hook up what you select in the dialog to what you apply as the preset. Does it write true or false into your ESTK console? This will tell you if your path in the code is pointing to a correct file. If not, swap it with the path that gets written to the console after the File.open dialog.

Or to hook it up to the file chosen in the dialog change:
calque.applyPreset(myPreset);
to
calque.applyPreset(thePreset);

Paul
bkan
Posts: 51
Joined: November 6th, 2013, 8:33 am

Paul Tuersley wrote:That code doesn't hook up what you select in the dialog to what you apply as the preset. Does it write true or false into your ESTK console? This will tell you if your path in the code is pointing to a correct file. If not, swap it with the path that gets written to the console after the File.open dialog.

Or to hook it up to the file chosen in the dialog change:
calque.applyPreset(myPreset);
to
calque.applyPreset(thePreset);

Paul
The ESTK console wrote "false".....

But even when I changed calque.applyPreset(myPreset); to calque.applyPreset(thePreset);,
the same error appears : "line 7 execution halted"
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Have you tried applying the preset manually to check it works ok?

Paul
bkan
Posts: 51
Joined: November 6th, 2013, 8:33 am

Yes, of course, it works. Have you tried the script on your machine? Does it works? I can't understand the "line 7 execution halted"!
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Yes it works fine for me. Of course I can't recreate exactly what you're doing. I'm using one of the included Adobe presets to test it. I created a comp with two solids, selected them both then ran the script. I did it both with a modified presetPath and by changing the last line to use the myPreset variable used in the File.openDialog method.

I don't recognise the "line 7 execution halted" error. Is that exactly what it says? Where does it say it? In an error dialog that comes up in AE? What version of AE are you running?

Paul
bkan
Posts: 51
Joined: November 6th, 2013, 8:33 am

OK, really strange : it works on AE CS5, but it fails with ae CS6......
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Hmm. I've been testing this in AE CC but just tried CS6 (all on Mac) and it worked. I realise you're on Windows though.
Have you tried it with other presets, such as the built-in Adobe ones? The only thing I can think of is that it's something about the preset. It uses some effect that isn't installed in CS6 or something. Obviously if you've tried it with other presets and it still isn't working in CS6 then it isn't that.

Paul
Post Reply