Advertisement
Guest User

Untitled

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