Adding an animation preset with a script

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Ed Smith
Posts: 19
Joined: October 22nd, 2007, 3:57 am
Location: Dublin, Ireland
Contact:

Basically, I've created a custom effect (using the tutorial on AETuts) and now I'm wondering if I can implement this using Compify (Byron Nash, Edited and Improved by Paul Tuersley). What I want to do is create the comps and then have this animation preset applied. My first impressions are that it may be possible to apply an animation preset but because the effectsGroup of my custom effect isn't defined I may have some trouble.

It'd be nice to be able to direct these newly generated comps into a specified folder aswell.
It's not the dog in the fight, it's the fight in the dog that matters.
Ed Smith
Posts: 19
Joined: October 22nd, 2007, 3:57 am
Location: Dublin, Ireland
Contact:

OK ok ok...I was being a lazy idiot. I found the language I needed.
It's not the dog in the fight, it's the fight in the dog that matters.
Ed Smith
Posts: 19
Joined: October 22nd, 2007, 3:57 am
Location: Dublin, Ireland
Contact:

is it possible to just specify a folder name and set that as the parentFolder for an object?

For example:

Code: Select all

var compFolder = app.project.item.name("CHAR PRECOMPS");
newComp.parentFolder = compFolder;
entire script (which I shamelessly canniballised from Compify (Byron Nash, Edited and Improved by Paul Tuersley):

Code: Select all

//select comps in project window and make comps from them
//add line boil preset to layer within created comp

app.beginUndoGroup("Precomp and Lineboil");

var selItems = app.project.selection;//set selected import items to an array
var myColl = app.project.selection;//use the selection
var i = 0;

//remove unneeded characters from comp name
for (i; i<myColl.length; i++) {
//add suffux to comp name and remove the file extension
var curItem = myColl[i];
var curName = curItem.name.substring(0, curItem.name.length-16);

//set comp to footage item dimensions and framerate
var curWidth = curItem.width;
var curHeight = curItem.height;
var curAspect = curItem.pixelAspect;
var curDuration = curItem.duration;
var curRate =  curItem.frameRate;

//create comp and add layer and add preset
var newComp = projColl.addComp(curName + "_LB",curWidth,curHeight,curAspect,curDuration,curRate);//make new comp
var lcoll = newComp.layers;//variable for collection of layer objects in logoComp
lcoll.add(curItem);//add layer
var presetPath = "w:/Gumball/AE_Custom_Effects/CE_LINE_BOIL_V002.ffx";
var myPreset = File(presetPath);
newComp.layer(1).applyPreset(myPreset);

//direct comp to precomps folder
var compFolder = app.project.item.name("CHAR PRECOMPS");
newComp.parentFolder = compFolder;
}

app.endUndoGroup();
It's not the dog in the fight, it's the fight in the dog that matters.
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

You can't access items in the project bin by name, but it's pretty simple to put together a little function to do it for you. Here's one what will find a folder with the specified name and return it (or null if the folder doesn't exist):

Code: Select all


  function getFolder(theName){
    var myFolder = null;
    for (var i = 1; i <= app.project.numItems; i++){
      if (app.project.item(i).name == theName && app.project.item(i) instanceof FolderItem){
        myFolder = app.project.item(i);
        break;
      }
    }
    return myFolder;
  }

Then in your main routine, just do something like this:

Code: Select all


var compFolder = getFolder("CHAR PRECOMPS");
if (compFolder == null) {
  // probably create the folder here
}else{
  newComp.parentFolder = compFolder;
}
Dan
Ed Smith
Posts: 19
Joined: October 22nd, 2007, 3:57 am
Location: Dublin, Ireland
Contact:

Awesome! The great Dan Ebberts stikes again. Thanks a million for this, this is the first time I've tried writing a script but it certainly wont be the last. I'm a bit late for Lloyds class on FXPHD but I'm hoping to include something similar for next term. Thanks again.
It's not the dog in the fight, it's the fight in the dog that matters.
Post Reply