Thread View: adobe.after.effects.scripting.render
1 messages
1 total messages
Started by jdnorthrup
Wed, 28 Jul 2004 20:15
BUG & FIX: importFile() function AfterEffects 6.5 WIN
Author: jdnorthrup
Date: Wed, 28 Jul 2004 20:15
Date: Wed, 28 Jul 2004 20:15
42 lines
2527 bytes
2527 bytes
Hi all --
have been having fun with javascript in afx, but i ran into a bug with the built-in function importFile.
when i import multiple files in a script, successive calls to importFile return the FootageItem that was imported first, not each new item added. this is clearly not what's stated in the scripting guide.
for example, run this script on a project with at least three footage files already added:
var sources = app.project.items; var myfname = sources[1].file.fsName;
alert(app.project.importFile(new ImportOptions(new File(myfname))).id);
myfname = sources[3].file.fsName; alert(app.project.importFile(new ImportOptions(new
File(myfname))).id); myfname = sources[5].file.fsName; alert(app.project.importFile(new
ImportOptions(new File(myfname))).id);
will incorrectly display the same id for each newly imported file.
the files themselves are imported correctly, but the returned item is wrong.
here's a function that works as intended:
// bug-fix for the built-in importFile function;
// returns proper FootageItem added
function importFile(theProject, myImportOpt) {
// store the id's of the current FootageItems in an array
var sources = theProject.items;
var ids = new Array(sources.length+1);
for (var i = 1; i <= sources.length; i++) { if(sources[i] instanceof FootageItem) { ids[i] = sources[i].id; } }
// import the file and throw away the reference returned
theProject.importFile( myImportOpt );
// search for the new id and return the new FootageItem
sources = theProject.items;
for (var i = 1; i <= sources.length; i++) { if(sources[i] instanceof FootageItem) { if (ids[i] != sources[i].id) { return sources[i]; } } } }
enjoy!
jd
vision wise, inc.
jdn at raintone dot com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads