Advertisement
Guest User

Untitled

a guest
Jun 15th, 2022
26
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(){
  2.  
  3. var comp = app.project.activeItem;
  4. var layers = comp.selectedLayers;
  5. var markers = comp.markerProperty;
  6.  
  7. // MOVE LAYERS TO MARKERS
  8. app.beginUndoGroup("Move Layers to Markers");
  9. for (var l = 0; l < layers.length; l++) {
  10.     for (var m = 1; m <= markers.numKeys; m++) {
  11.         var layerName = layers[l].name.split(' - ')[0];
  12.         var markerName = markers.keyValue(m).comment.split(' - ')[0];
  13.         var markerTime = markers.keyTime(m);
  14.             if (layerName == markerName) {
  15.                 layers[l].startTime = markerTime;
  16.                 break;
  17.             }
  18.         }
  19. }
  20. app.endUndoGroup();
  21.  
  22.  
  23. app.beginUndoGroup("Set Keyframes");
  24. // PARAMETERS
  25. var startTime = app.project.activeItem.selectedLayers.inPoint;
  26. var waitFrames = 5;
  27. var fps = comp.frameRate;
  28. var frameGap = waitFrames / fps;
  29. var endTime = startTime + frameGap;
  30. var spacingY = 60;
  31. var startPosX = 950;
  32. var moveX = 300;
  33. var endPosX = startPosX + moveX;
  34. var startPosY = 100;
  35.  
  36. function deleteAllKeys(theProperty) {
  37.     while (theProperty.numKeys) {
  38.         theProperty.removeKey(1);
  39.     }
  40. }
  41.  
  42. for (var i = 0; i < layers.length; i++) {
  43.     var layerPosX = layers[i].transform.position.getSeparationFollower(0);
  44.     var layerPosY = layers[i].transform.position.getSeparationFollower(1);
  45.     var layerOpacity = layers[i].property("Opacity");
  46.     var layerScale = layers[i].property("Scale");
  47.     var name1 = layers[i].name.split('-')[0];
  48.     var name2 = name1.split(' ')[0];
  49.         if (name2 == "SHAPE") {
  50.             // DELETE ALL KEYFRAMES
  51.             deleteAllKeys(layerPosX);
  52.             deleteAllKeys(layerPosY);
  53.             deleteAllKeys(layerOpacity);
  54.             deleteAllKeys(layerScale);
  55.             // SET IN ANIMATION KEYFRAMES
  56.             layerOpacity.setValueAtTime(layers[i].inPoint, 0);
  57.             layerOpacity.setValueAtTime(layers[i].inPoint+frameGap, 100);
  58.             layerPosX.setValueAtTime(layers[i].inPoint, startPosX);
  59.             layerPosX.setValueAtTime(layers[i].inPoint + frameGap, endPosX);
  60.             layerPosY.setValueAtTime(layers[i].inPoint, startPosY);
  61.                 // SET SHIFTING ANIMATION KEYFRAMES
  62.                 for (var j = 1; j < layers.length; j++) {
  63.                     if (i < layers.length - j) {
  64.                         layerPosY.setValueAtTime(layers[i + j].inPoint, startPosY + spacingY * (j - 1));
  65.                         layerPosY.setValueAtTime(layers[i + j].inPoint + frameGap, startPosY + spacingY * j);
  66.                     }
  67.                 }
  68.         }
  69. }
  70. app.endUndoGroup();
  71. })()
Advertisement
RAW Paste Data Copied
Advertisement