Advertisement
Guest User

Untitled

a guest
Mar 15th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. // Helper variables
  2. var proj = app.project; // active project
  3. var comp = proj.activeItem; // active comp
  4. var layer = comp.selectedLayers; // selected layers
  5. var numLayers = comp.numLayers; // count of comp layers
  6.  
  7. function setupLayers()
  8. {
  9.  
  10. for (i = 1; i <= numLayers; i++)
  11. {
  12. var layer = comp.layer(i);
  13. var effectsGroup = layer("Effects");
  14. var effectsOnLayer = [];
  15.  
  16. if (effectsGroup !== null)
  17. {
  18. for (var v = 1; v <= effectsGroup.numProperties; v++)
  19. {
  20. effectsOnLayer[effectsOnLayer.length] = effectsGroup.property(v);
  21. }
  22. }
  23.  
  24. for (var k = 0; k < effectsOnLayer.length; k++)
  25. {
  26. if (effectsOnLayer[k].matchName === "ADBE Set Matte3")
  27. {
  28. layerEffectIndex = k+1;
  29. layerRefIndex = effectsOnLayer[k].property(1).value;
  30. arr = [layerEffectIndex,layerRefIndex];
  31.  
  32. effectsOnLayer[k].name += " $" + arr.toString();
  33. comp.layer(layerRefIndex).comment = layerRefIndex;
  34. }
  35. }
  36. }
  37.  
  38. }
  39.  
  40. function findLayerByComment(commentToFind)
  41. {
  42. for (i = 1; i <= numLayers; i++)
  43. {
  44. if (comp.layer(i).comment === commentToFind.toString())
  45. {
  46. return i;
  47. }
  48. }
  49. }
  50.  
  51. function resetLayers()
  52. {
  53. for (i = 1; i <= numLayers; i++)
  54. {
  55. var layer = comp.layer(i);
  56. var effectsGroup = layer("Effects");
  57. var effectsOnLayer = [];
  58.  
  59. if (effectsGroup !== null)
  60. {
  61. for (var v = 1; v <= effectsGroup.numProperties; v++)
  62. {
  63. effectsOnLayer[effectsOnLayer.length] = effectsGroup.property(v);
  64. }
  65. }
  66.  
  67. for (var k = 0; k < effectsOnLayer.length; k++)
  68. {
  69. if (effectsOnLayer[k].matchName === "ADBE Set Matte3")
  70. {
  71. originalName = effectsOnLayer[k].name.split("$")[0];
  72. arr = effectsOnLayer[k].name.split("$")[1].split(",");
  73.  
  74. effectsOnLayer[k].property(1).setValue(findLayerByComment(arr[1]));
  75. effectsOnLayer[k].name = originalName.substring(0,originalName.length-1);
  76. }
  77. }
  78. }
  79.  
  80. for (i = 1; i <= numLayers; i++)
  81. {
  82. comp.layer(i).comment = null;
  83. }
  84.  
  85. }
  86.  
  87. //setupLayers();
  88. //resetLayers();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement