Skip to content

Instantly share code, notes, and snippets.

@dvschultz
Created February 3, 2025 22:03
Show Gist options
  • Select an option

  • Save dvschultz/eef3e0736603ed6c416bfc2dcf8d1271 to your computer and use it in GitHub Desktop.

Select an option

Save dvschultz/eef3e0736603ed6c416bfc2dcf8d1271 to your computer and use it in GitHub Desktop.
Randomize layers in Adobe After Effects
{
var myComp = app.project.activeItem;
var n = myComp.numLayers;
var myLayers = [];
var myIdx = [];
for (var i = 1; i<= n; i++){ myIdx[i-1] = i; myLayers[i-1] = myComp.layer(i); } var idx; var temp; for (var i = 0; i < myIdx.length; i++){ idx = i + Math.floor(Math.random()*(myIdx.length - i)); temp = myIdx[i]; myIdx[i] = myIdx[idx]; myIdx[idx] = temp; } for (var i = 0; i < myIdx.length; i++){ myLayers[myIdx[i]-1].moveToBeginning(); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment