ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Could you offer a solution with a line of code? trying my template into a good direction.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Marc Konings
Could you offer a solution with a line of code? trying my template into a good direction.
on Jun 17, 2017 at 10:41:40 am

Hello community.
I am looking for a way to create a template for a series I am working on.

I made a base template with a comp called _SCENE. This is the work composition and I am trying to get all elements in this comp when importing.
So far so good, till I want to import a .psd.

I seem not to find that part of code (I am REALLY new to coding) that gives me the standard after effects pop-up window, when importing manually a photoshop document.


Could you help me out please?

Cheers,


Marc Konings


Below is the code I have till now:













/* TEMPLATE AE COMPOSITING production name */

// MK

// version 15062017-002



var currentFootageItem;

var maDate=new Date();

var myfps=25;

var mySearch=/EP000_SC000/;

var nom=prompt("Episode and Scene number :","EP000_SC000","production name AE");

var myDuree=prompt("Frames : ","480","production name AE")/25;

var z,z1=false;

var myDoc = app.activeDocument

var myProject = app.project.items;

var q = app.project.renderQueue.items

var folderProjectName = myProject.addFolder(nom);



var folderScene = myProject.addFolder("07_SCENE");

var folderRenderComp = myProject.addFolder("RENDER_COMPS");

var folderOther = myProject.addFolder("05_OTHER");

var folderComps = myProject.addFolder("06_COMPS");

var folderAnimaticRefs = myProject.addFolder("01_ANIMATIC & REFS");

var folderAnim = myProject.addFolder("02_ANIM");

var folderBg = myProject.addFolder("03_BG");

var folderFx = myProject.addFolder("04_FX");



folderScene.parentFolder=folderProjectName;

folderRenderComp.parentFolder=folderProjectName;

folderOther.parentFolder=folderProjectName;

folderComps.parentFolder=folderProjectName;

folderAnimaticRefs.parentFolder=folderProjectName;

folderAnim.parentFolder=folderProjectName;

folderBg.parentFolder=folderProjectName;

folderFx.parentFolder=folderProjectName;



alert("Choose your ANIMATIC file");

var animatic = File.openDialog("Select ANIMATIC");

if(animatic != null) {

var myImportOptions = new ImportOptions();

myImportOptions.file = animatic;

var myAnimatic = app.project.importFile(myImportOptions);

myAnimatic.parentFolder = folderAnimaticRefs;

for (it=myProject.length; it>=1; it--){

if(myProject[it].name==nom+"_SCENE"){

myProject[it].layers.add(myAnimatic)

}



}





}

alert("Choose your PHOTOSHOP / BG file");

var bg= File.openDialog("Select BACKGROUND / .PSD");

if(bg != null) {

var myImportOptions2 = new ImportOptions();

myImportOptions2.file = bg;

var myBg = app.project.importFile(myImportOptions2);

myBg.parentFolder = folderBg;



//I am struggling here, I seem not to get to choose a .psd AND to choose in what way I want to import this .psd

//It would be awesome if I could import this also instantly in 'comp_SCENE'.



}

{

if(myImportOptions2.canImportAs(ImportAsType.COMP)){

myImportOptions2.importAs = ImportAsType.COMP;

}else{

myImportOptions2.ImportAs=ImportAsType.FOOTAGE;



for (it=myProject.length; it>=1; it--){

if(myProject[it].name==nom+"_SCENE"){

myProject[it].layers.add(myAnimatic)

}

}



}

alert("Choose your ANIMATION folder");

var mySwfFolder = Folder.selectDialog ("Select ANIMATION Folder");

var mySwfFiles = mySwfFolder.getFiles ("*.SWF");

for(var i = 0; i &lt; mySwfFiles.length; i++){

var myImportOptions3 = new ImportOptions();

myImportOptions3.file =mySwfFiles[i]

var mySwf = app.project.importFile(myImportOptions3);

mySwf.parentFolder = folderAnim;

for (it=myProject.length; it>=1; it--){

if(myProject[it].name==nom+"_SCENE"){

myProject[it].layers.add(mySwf)

}



}

};

for (i=app.project.numItems; i>=1; i--){

if(mySearch.test(myProject[i].name)){

myProject[i].name=myProject[i].name.replace(mySearch,nom)

myProject[i].duration=myDuree;

z=true;



if(myProject[i].name==nom+"_NOMENCLATURE"){

for(j=1;j&lt;=myProject[i].numLayers;j++){

if(mySearch.test(myProject[i].layer(j).name)){

myProject[i].layer(j).sourceText.setValue(nom);

myProject[i].layer(j).name=nom;

z1=true;

}

}

}

}

}

if(z&&z1){



// Folder creation + variable of each ones creation b = folderProjectName





for (i2=myProject.length; i2>=1; i2--){



if(myProject[i2].name==nom+"_SCENE"){myProject[i2].parentFolder=folderScene;}

if(myProject[i2].name==nom+"_QT_T1"){myProject[i2].parentFolder=folderRenderComp;}

if(myProject[i2].name==nom+"_NOMENCLATURE"){myProject[i2].parentFolder=folderOther;}

if(myProject[i2].name==nom+"_CONFO_T1"){myProject[i2].parentFolder=folderRenderComp;}



if(myProject[i2].name==nom&&!(myProject[i2] instanceof FolderItem)){

myProject[i2].parentFolder=folderProjectName;

myProject[i2].selected=true;

currentFootageItem=myProject[i2]

}

myProject[i2].selected=false

}



function aff_Date(x){

if(x>9){

return x;

}

else{

return "0"+x;

}

}

var d=app.project.saveWithDialog();

var e=app.project.file.path;

var f=app.project.file.fsName;

var h = e.toString().split("/");

h.pop();

var g="";



for (i=0;i<h.length;i++){

g=g+h[i]+"/";

}



g=g+ "OUTPUT_"+nom+"/" + nom + "_QT_T1_"+maDate.getFullYear().toString().substring (2,4)+aff_Date(maDate.getMonth()+1)+aff_Date(maDate.getDate());

var curItemQ = q[1];

var curItemQOut = curItemQ.outputModule(1);

// var oldLocation = curItemQOut.file;

curItemQOut.file = new File(g);

var w="";

for (i=0;i<h.length;i++){

w=w+h[i]+"/";

}

w=w+ "OUTPUT_"+nom+"/" + nom + "_CONFO_T1_[#####]_"+maDate.getFullYear().toString().substring (2,4)+aff_Date(maDate.getMonth()+1)+aff_Date(maDate.getDate());

var curItemQ = q[2];

var curItemQOut = curItemQ.outputModule(1);

// var oldLocation = curItemQOut.file;

curItemQOut.file = new File(w);



}

else{

alert ("Script stopped working : The AE project doesn't look like a copy of the template: EP000_SC000.aet" , "Production name AE", true)
}


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]