/**
 * @source https://github.com/ff6347/after-effects-script-snippets/blob/master/sort_text_layers_by_content.jsx
 * @author fabiantheblind
 * @description this sorts layers by their content
 *
 *
 * @todo [description]
 */

 function main() {
    str = 'one,two,three,four' 
 
   app.beginUndoGroup('XXX');
 
   var curComp = app.project.activeItem;
   if (!curComp || !(curComp instanceof CompItem)) {
     alert('noComp');
     return;
   }
 
   var arr = str.split(',');

   var layers_to_move = [];
   for(var i = 0; i < arr.length; i++) {
     for(var l = 0; l < curComp.selectedLayers.length; l++) {
       var layer = curComp.selectedLayers[l];
       if(arr[i] == layer.text.sourceText.value) {
 // ~                 alert("Found " + arr[i] );
         layers_to_move.push(layer);
         break;
       }
     }
   }
 
   for(var j = 0; j < layers_to_move.length; j++) {
       alert(layers_to_move[j].index)
     layers_to_move[j].moveToBeginning();
   }
 
   app.endUndoGroup();
 
 
 }
 main();

 

您的电子邮箱地址不会被公开。 必填项已用*标注