top of page

Expressions

Ball bounce scale and decay (apply to Scale)

//Ball bounce scale and decay (apply to Scale)
//duh_ballScaleBounceDecay by danit uziel

freq =3; 
amplitude = 35; 
decay = 1.0; 

s = amplitude*Math.sin(freq*time*2*Math.PI)/Math.exp(decay*time);
scale + [s,s]

Ball bounce and decay (apply to Position)

//Ball bounce and decay (apply to Position)
//duh_ballBounceDecay by danit uziel

freq = 1.0; //oscillations per second 
amplitude =  90; 
decay =  .5;

posCos = Math.abs(Math.cos(freq*time*2*Math.PI));
y = amplitude*posCos/Math.exp(decay*time);
position - [0,y]

Wiggle scale at marker of layer (apply to scale)

//Wiggle scale at marker of layer (apply to scale)
//duh_WigleAtMarker by danit uziel


n = 0;
t = 0;

if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time) n--;
}

if (n > 0) t = time - marker.key(n).time;

amp = 15;
freq = 5;
decay = 3.0;

angle = freq * 2 * Math.PI * t;
scaleFact = (100 + amp * Math.sin(angle) / Math.exp(decay * t)) / 100;
[value[0] * scaleFact, value[1] / scaleFact];

wiggle position from start to stop (apply to Position)

//---------------------------------------
//
wiggle position and set limits (apply to Position)
v=wiggle(5,50);
if(v < 50)v=0;
if(v > 50)v=100;
v

//TypeWriter(apply to Source Text)
//write text that will appear as typing

fps = 1/thisComp.frameDuration;
cursorSpeed = 3;
text.sourceText.slice(0,time*fps)+((Math.floor(time*cursorSpeed)%2)?"|":" ");

//-------------------------------------------Number Expressions--------------------------------

//add commas to number  "1,000,000", controlled by slider (apply to Source Text)
//duh_numberWcomma by danit uziel

addCommas(effect("Slider Control")("Slider").value.toFixed(0))

function addCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

//Random number at a range of 100 (apply to Source Text)

//duh_randomNumber by danit uziel
r=100
Math.floor(random()*r)

//-------------------------------------------Timer Countdown--------------------------------

 

//------------------1----------------------------------------


//Countdown Timer (apply to Source Text)
//30 minutes count back "30:00"
//duh_CountDwn by danit uziel

t = Math.floor(time);
s = 1800 - t;
minutes = Math.floor(s/60);
seconds = s-(minutes*60);
if(seconds < 10)
{
    seconds = '0' + seconds;
}
minutes + ':' + seconds;

 


//------------------2----------------------------------------


//Countup Timer (apply to Source Text)
//count up from zero "0:00"
//duh_CountUp by danit uziel

t = Math.floor(time);
s = t;
minutes = Math.floor(s/60);
seconds = s-(minutes*60);
if(seconds < 10)
{
    seconds = '0' + seconds;
}
minutes + ':' + seconds;


//--------------------3------------------------------------------
//count up from zero "00:00:00:00"
//duh_CountUp by danit uziel

timeToCurrentFormat()


//------------------4-------------------------------
//
count up from zero "00:00:00", controlled by slider (apply to Source Text)
//duh_CountUp by danit uziel

t = effect("Slider Control")("Slider");
sign = (t<0)?'-':'';
t = Math.abs(t);

s = Math.floor(t%60);
m = Math.floor(t/60)%60;
h =  Math.floor(t/ (60*60));
h =  (h<10)?'0'+h:h;
s =  (s<10)?'0'+s:s;          // pads
m = (m<10)?'0'+m:m;

sign+h+':'+m+':'+s;

//wiggle position from start to stop (apply to Position)
//duh_WigleStop_strt  by danit uziel

timeToStart = 2;
timeToStop = 4;

if ((time > timeToStart) && (time < timeToStop)) {
  wiggle(3,25);
} else {
  value;
}

Script and syntax

$.writeln("__________________");​

App

var myProj = app.project;
var myComp = myProj.activeItem; //app.project.activeItem;
if (myComp == null){ //No composition was selected in the Project Panel
    alert("Please select a composition");
}

var layers = myComp.layers; //get an array of layers
var numLayers = layers.length; //get the number of layers in the composition [starts counting from 1]

var myLayer = myComp.selectedLayers[0];//first layer selected

app.project.selection.length

var properties = app.project.activeItem.selectedProperties;
var numProperties = properties.length;

var PlayheadT=app.project.activeItem.time;

var frame = PlayheadT / app.project.activeItem.frameDuration; 

//Array of the items in the project panel
app.project.items;

 

//numItems in project panel - including folders and all types of footage
app.project.numItems;

 

//Moves this layer to the topmost position of the layer stack (the first layer).
app.project.activeItem.selectedLayers[0].moveToBeginning();

myLayer.locked = true;

 

/move selected layer to playhead time
app.project.activeItem.selectedLayers[0].inPoint=app.project.activeItem.time;


comp.workAreaStart = 0;
comp.workAreaDuration = comp.duration;

//All items selected in the Project panel
var prjSlct=app.project.selection;

if (prjSlct.length<1){//check if selected any item from project panel
        alert("You need to select composition\s");
}    

if (app.project.activeItem.selectedLayers.length==0){
    alert("Please select a layer");
}

Time

//move the playhead of composition to the begining
app.project.activeItem.time = 0;

//save the current time of the play head
var time=app.project.activeItem.time;
var frame = time / app.project.activeItem.frameDuration; //frame number

 

Show Panels

//hide or show the project panel
app.project.showWindow(true/false);

//open and show in viewer the composition selected

app.project.activeItem.openInViewer();

//show the viewer panel
app.activeViewer.setActive();

 

//Shows or hides the Render Queue panel.
app.project.renderQueue.showWindow(true/false);

//Display the name of the 12 effect of the application//..displayName/.category/.matchName

var effectName = app.effects[12].displayName;

App commands

app.purge();

 

app.executeCommand(2003);//import files

app.beginUndoGroup("Type Name of action");

app.endUndoGroup();

// when true, errors that have occurred following the call to beginSuppressDialogs() are displayed in adialog box.

app.beginSuppressDialogs();
app.endSuppressDialogs(true/false);

//Remove unused footage

var numNotUsed=app.project.removeUnusedFootage();

Property

//property.setValueAtTime(myComp.time+timeDif,keyVal[p]);
//property.removeKey(property.nearestKeyIndex(keyT[p]));
//comp.selectedLayers[0].property(1).numKeys
//comp.selectedLayers[0].numProperties
//$.writeln(comp.selectedLayers[0].property("Transform").numProperties);

Comp
var rendComp = app.project.items.addComp("duh_rendComp",activeComp.width,activeComp.height,

activeComp.pixelAspect,activeComp.workAreaDuration,activeComp.frameRate);
var dupComp = activeComp.duplicate();//duplicate the comp and make changes to it
dupComp.name= activeComp.name + "_"+ indexT[1];
dupComp.parentFolder = rendFolder ;
dupComp.selected = true; //setActive();
dupComp.layers.add(svAudioLayer); 

Folder

var myFolder = new Folder("C:/My Folder"); 
app.project.setDefaultImportFolder(myFolder);
app.project.setDefaultImportFolder(new Folder("C:/My Folder"));
app.project.setDefaultImportFolder(Folder("C:/My Folder"));
if(myFolder.numItems==0){//folder is empty

Comp Folder

var compFolder=getFolderByName("duh-sound");
//var compFolder=app.project.items.addFolder("duh-sound");

 

Filename

//$.fileName -  "~/Documents/danit/myWeb/this.jsx"
//app.project.file - "~/Documents/danit/myPrj.aep"
//var scriptFolderPath = File($.fileName).path;
var FileName=File($.fileName).parent.path + "/duh_versions.txt";
if(app.project.file !== null){//is saved project?

 

//alert("enter your meesage here");
newNm=prompt("Choose a name to add","בקרוב");
if (newNm==null)
    return;
var vtryMe=confirm("Please select audio files to import");
if (!vtryMe)
    return;

   //-----------------------------------------FUNCTIONS---------------------------------------------
/*BridgeTalk and AME*/
var bt = new BridgeTalk();
var ameStatus = BridgeTalk.getStatus("ame");
    if (ameStatus == "ISNOTINSTALLED"){
        alert("Media Encoder is not installed");
      }//if installed
  //alert(ameStatus);
  if (ameStatus == "ISNOTRUNNING"){
        BridgeTalk.launch("ame"); // This can take a while; let's get the ball rolling.
    }
/*BridgeTalk and AME*/

/*check if ae allows writing files*/
var isWritb=app.preferences.getPrefAsLong("Main Pref Section","Pref_SCRIPTING_FILE_NETWORK_SECURITY");
    //0=no, 1=allow scripts to write files
    
if(Number(isWritb)==0){
     alert( "The script requires access to write files.\n" +
            "Go to the \"Scripting and expressions\" panel of the application preferences and make sure " +
            "\"Allow Scripts to Write Files and Access Network\" is checked.");
    app.executeCommand(2359);
    return null;
}
/*check if ae allows writing files*/      

 

/*open file or save file*/
var myFile1 =File(FileName);// File.openDialog("Please select input text file.");
var fileOK = myFile1.open("r");
if (fileOK){          
    while (!myFile1.eof){
        text = myFile1.readln();
    }//while EOF
    myFile1.close();
}else{
  alert("File open failed!");
}
var encoding = encoding || "utf-8";
myFile.encoding = encoding;
fileOK = myFile.open("w");
if (fileOK){
    fileOK=myFile.write(text);
}//end if
else{
    alert("File open failed!");
}


var my_file = new File("../my_folder/my_test.aep");
if (my_file.exists) {
  new_project = app.open(my_file); 
  if (new_project) {
    alert(new_project.file.name);
  }
}


//-----------------------------------------FUNCTIONS---------------------------------------------
/*function CheckIsComp*/
function CheckIsComp(itemName){ //app.project.item(0)
    if (itemName instanceof CompItem)
        return true;
     else
        return false;
}
/*function CheckIsComp*/

      
/*search all items in the project panel and return the comp if exists , if not a comp or doesnt exist return null*/
function getComp(theName){//sending the comp name and getting the object  in return
   for (var i = 1; i <= app.project.numItems; i++){
        //if ((app.project.item(i) instanceof CompItem || app.project.item(i) instanceof TextLayer)
     
       if ( (app.project.item(i).name == theName)){
            //alert(app.project.item(i).name );
            if (!(CheckIsComp(app.project.item(i)))){
                alert(theName + " is not a comp and can not replace it");
                return null;
                }

            return app.project.item(i);
       }
        
   }
    alert("A comp named "+theName +" does not exist");
   return null;
}

    
function  deSelectComps(){
    for (var i = 1; i<=app.project.numItems; i++) {
            app.project.item(i).selected=false;
    }
}//end deSelectComps

 

function getFolderByName(folderName) {
    var myProject = app.project;
    for (var i = 1; i <= myProject.numItems; i++) {
        if ((myProject.item(i) instanceof FolderItem) && (myProject.item(i).name == folderName)){
            return myProject.item(i);
        }
    }
    //var compFolder=app.project.items.addFolder("duh-sound");
    myFolder = myProject.items.addFolder(folderName);
    return myFolder;   
    //var scFolder = Folder('/c/MaxFilesNumber')
      //  if(!scFolder.exists) scFolder.create()
}

    function getRandomNumber(min, max) {
        return Math.random() * (max - min) + min;
    }

   
function isKeyAtThisTime(prop, time) {
   for(var i = 1; i <= prop.numKeys; i++) {
       if(prop.keyTime(i) == time) {
           return true;
       }
   }

    return null;
}

 

bernie's

Render Tom

Kyle Martinez

 Zack Lovatt's Scriptlets

rd: scripts

for script ui builders

AFTER EFFECTS MENU COMMAND ID LIST

Created by: David Torno

bottom of page