image export/import script won't work, need guru help


hi guys, try export image ae png file , import file ae adding timeline via script, exporting working excellent importing not work....

script:

 

function test()

{

var myproj = app.project;

var mycomp = myproj.activeitem;

app.project.activeitem.saveframetopng(app.project.activeitem.time, new file("c:\\users\\username\\desktop\\1111\\2test.png"));

var importoptions = new importoptions("c:\\users\\username\\desktop\\1111\\2test.png");

var importimg = app.project.importfile (importoptions);

mycomp.layers.add(importimg);

}

 

thanks

you not referencing file object importoptions argument, string. may want cleanup function bit too.

 

instead of this:

function test(){

     var myproj = app.project;

     var mycomp = myproj.activeitem;

     app.project.activeitem.saveframetopng(app.project.activeitem.time, new file("c:\\users\\username\\desktop\\1111\\2test.png"));

     var importoptions = new importoptions("c:\\users\\username\\desktop\\1111\\2test.png");

     var importimg = app.project.importfile (importoptions);

     mycomp.layers.add(importimg);

}

 

try this setup. it's little more organized , don't need call activeitem everytime, 1 time , store in variable.

 

function test(){

     var myproj = app.project;

     var mycomp = myproj.activeitem;

     var myfile = new file("c:\\users\\username\\desktop\\1111\\2test.png");

     if(mycomp instanceof compitem){

          mycomp.saveframetopng(mycomp.time, myfile);

          var importoptions = new importoptions(myfile);

          var importimg = myproj.importfile (importoptions);

          mycomp.layers.add(importimg);

     }

}



More discussions in After Effects Scripting


adobe

Comments

Popular posts from this blog

Thread: Can not create raid array: mdadm: no raid-devices specified.

Thread: HOW TO: Package and theme GTK+ / Gtkmm apps in Linux for Windows

Thread: Twinview issues