Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Applying animation presets to solid via scripting

  • Applying animation presets to solid via scripting

    Posted by Ben Christie on July 27, 2015 at 11:24 pm

    Hello!

    I am currently working on a script that will help my colleagues generate some of the animations I use the most. Rather than having them dig into animation presets I am creating a floating script panel to make things faster.

    I currently have a script to create a new solid but now need to call from a series of animation presets in a folder titled “PluginResource” and apply it to the new solid.

    I also need to call these animation presets even if I were to switch over to a Mac that does not have the same path file.

    Been stumped on this one for a while.

    Any help would be great!

    Ben Christie replied 10 years, 9 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 28, 2015 at 12:35 am

    Maybe you could set the script up so that it first tries the obvious paths to find the folder. If it can’t, then it pops up the system navigate-to-folder dialog to have the user sync it up. You could then save that path in the preferences so that the script will find it next time.

    Dan

  • Ben Christie

    July 28, 2015 at 1:03 am

    That would make a lot of sense. That would allow my colleagues to kind of set it up themselves which would be great.

    Unfortunately I’m not quite sure how to do that, let alone apply a preset from a defined folder.

    Would it be something similar to this?

    var thePreset = new File(“/Applications/Adobe After Effects CC 2014/Presets/PluginResource/Custom Preset.ffx”);

    if (thePreset.exists == true) {
    theLayer.applyPreset(thePreset);
    } else {
    // here would be the function to have the user set the custom path and then save it??
    }

  • Xavier Gomez

    July 28, 2015 at 11:25 am

    * To ask for the folder path, you can use:

    var myPresetsFolder = Folder.selectDialog();

    or :

    var allPresetsFolder = Folder(Folder.appPackage.absoluteURI + “/” + “Presets”);
    var myPresetsFolder = allPresetsFolder.selectDlg();

    (The 2 methods dffer in that in the latter case the dialog “has already navigated to a closer place”.)

    * To read/write in the prefs file, use the app;settings object:

    var allPresetsFolder = Folder(Folder.appPackage.absoluteURI + "/" + "Presets");
    var myPresetsFolder;

    // read the settings
    if (app.settings.haveSetting("MyScriptSection", "myPresetsFolderPath")){
    myPresetFolder = new Folder(app.settings.getSetting("MyScriptSection", "myPresetsFolderPath"));
    };
    if (!myPresetFolder || !myPresetFolder.exists){
    // if the folder does not exist, ask for the path
    myPresetsFolder = allPresetsFolder.selectDlg();
    if (myPresetsFolder && myPresetsFolder.exists){
    // if now it exists, save the path
    app.settings.saveSetting("MyScriptSection", myPresetsFolder.absoulteURI);
    };
    };
    // Beware, at this stage the variable myPresetsFolder can still be null, if the user was prompted a folder dialog and closed it.

    Xavier.

  • Ben Christie

    July 28, 2015 at 5:27 pm

    Wow this helps a lot. I Really appreciate it!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy