"Split and move in timeline" expression

Scripting for After Effects

"Split and move in timeline" expression

Postby thanulee on 11/26/2014, 6:55 am

Hello. I wanna do the following with a single button (cause it takes too long when i do it manually for so many clips):

Split the selected layer 20 frames after the time that I am (eg. if I am at 1:00 i need the split at 1:20) and move the new split part that is created 55 frames forward in the timeline (eg. if the start of the new split is at 2:00 it goes to 4:05 (im running at 25fps per sec))

Then i can assign this to a button and thats it!!!!
It would be a great timesaver!!! thanks ppl!
Posts: 158
Joined: 02/9/2012, 2:12 am

Re: "Split and move in timeline" expression

Postby dconklin on 12/1/2014, 9:11 am

It's quick and dirty, but this should get it done for you.

Run using File > Scripts > Run scripts file.

You can edit lines 36, 41, 42 and replace the 20, 55 respectively if you need new numbers.

Good luck!

Edit: Forum won't let me attach a .JSX (why?).

I'm pasting the code below. Open Extend Script Toolkit (included in your AE install), paste this dude in, and save w/ the extension .JSX.

Sorry about that!

Code: Select all

   function doLayerSplit(thisObj){

      function buildUI(thisObj){
         var w = (thisObj instanceof Panel) ? thisObj : new Window("Palette", "doSplitLayers");
            w.orientation = "row";

         var splitbtn = w.add("button", undefined, "Split");
         var cancelBtn = w.add("button", undefined, "Cancel");
         splitbtn.onClick = function(){
            app.beginUndoGroup("Split at Time Plus Twenty");

         cancelBtn.onClick = function(){

         return w;

      } //end build ui

      function mainFunction(numToSplit){

         var ai = app.project.activeItem;
         var theLayer = ai.selectedLayers[0];

         if(ai == null || theLayer == null) { alert("Please have an active comp and one selected layer!"); }

         var theInPoint = theLayer.inPoint;
         var theOutPoint = theLayer.outPoint;
         var theSplitPoint = ai.time +(20 * ai.frameDuration);

         theLayer.outPoint = theSplitPoint;
         var dupe = theLayer.duplicate();
         dupe.inPoint = theSplitPoint + (55 * ai.frameDuration);
         dupe.outPoint = theOutPoint + (55 * ai.frameDuration);


      var theWindow = buildUI(thisObj);
      if(theWindow instanceof Window){
      } else {

   } //end doLayerSplit


Posts: 19
Joined: 03/23/2011, 6:24 am

Re: "Split and move in timeline" expression

Postby thanulee on 12/6/2014, 1:39 pm

u are a god!!!
Posts: 158
Joined: 02/9/2012, 2:12 am

Return to After Effects Expressions