Page 1 of 1

Scripted equivalent of File>Import

Posted: March 9th, 2007, 11:14 am
by normschaef
Hi all:

I've just started to play with AE scripting this week and have found it both to be challenging and fun. (I come from a VB.NET and video production background)

I've already learned a great amount from this site by x-referencing with the Scripting Guide.

One question I haven't quit be able to get straight in my head from the guide and the examples is what steps are necessary to automate the File>Import command. (I've looked at the SmartImport.jsx) and it's a little confusing to me.

Adding various other layers seems pretty simple.
layers.addText()';
layers.addSolid(); .....

Seems like it would be really handy to have a
layers.addFile();

But instead it appears that I have to....well, I'm not quite sure what I have to do.

I've looked at the guide in footageSource, fileSource, CompItem and other places, but can't seem to make heads nor tails of it.

TIA for any help.
Norm

Importing files

Posted: March 9th, 2007, 10:06 pm
by redefinery
Hi Norm,

Look at the Project object's importFile() or importFileWithDialog() method to retrieve a FootageItem (or array thereof), and then use the LayerCollection object's add() method to add it as a layer. Something like:

Code: Select all

var fItem = app.project.importFile(File("myJPEGFileToImport.jpg"));
var layer = myComp.layers.add(fItem);   // myComp is the CompItem representing your comp
Hope this helps.

Jeff