Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

shuffle layer order

Community Beginner ,
Nov 29, 2024 Nov 29, 2024

hey everyone i wanted to shuffle layers randomly in after effect. I have around 50 layers and wanted to just rendomly shuffle i need any kind if script or free tool that can help me to ease my work rather than doing manually

 

for example:

 

(before shuffle)

layer 1

layer 2

layer 3

layer 4

layer 5

layer 6

layer 7

layer 8

layer 9

layer 10

 

(after shuffle)

layer 4

layer 7

layer 5

layer 1

layer 9

layer 3

layer 8

layer 10

layer 2

layer 6

TOPICS
Error or problem , How to , Resources , Scripting
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Nov 29, 2024 Nov 29, 2024

Here's a simple script that assumes all layers are participating:

function shuffleLayers(){
	function shuffleArray(theArray){
		var temp;
		var idx;
		for (var i = 0; i < theArray.length; i++){
			idx = i + Math.floor(generateRandomNumber()*(theArray.length-i));
			temp = theArray[i];
			theArray[i] = theArray[idx];
			theArray[idx] = temp;
		}
	}
	var myComp = app.project.activeItem;
	if (! (myComp && myComp instanceof CompItem)){
		alert ("No comp active.");
		return;
	}
	var myLayers = [];
	f
...
Translate
Advocate , Dec 02, 2024 Dec 02, 2024

Maybe your JSX file is not encoded in UTF-8,

otherwise try using QuickScript.

naaikk_786.gif

 

Translate
Community Expert ,
Nov 29, 2024 Nov 29, 2024

Here's a simple script that assumes all layers are participating:

function shuffleLayers(){
	function shuffleArray(theArray){
		var temp;
		var idx;
		for (var i = 0; i < theArray.length; i++){
			idx = i + Math.floor(generateRandomNumber()*(theArray.length-i));
			temp = theArray[i];
			theArray[i] = theArray[idx];
			theArray[idx] = temp;
		}
	}
	var myComp = app.project.activeItem;
	if (! (myComp && myComp instanceof CompItem)){
		alert ("No comp active.");
		return;
	}
	var myLayers = [];
	for (var i = 1; i <= myComp.numLayers; i++){
		myLayers.push(myComp.layer(i));
	}
	shuffleArray(myLayers);
	for (var i = 0; i < myLayers.length; i++){
		myLayers[i].moveToBeginning();
	}
}
shuffleLayers();
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 29, 2024 Nov 29, 2024

Appreciate your response, Dan.

Let us know if it helps, naaikk_786


Thanks,
Nishu

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 02, 2024 Dec 02, 2024

i have converted the code into ( JSX ) and run the script and im not able to use it 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 02, 2024 Dec 02, 2024

Maybe your JSX file is not encoded in UTF-8,

otherwise try using QuickScript.

naaikk_786.gif

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 03, 2024 Dec 03, 2024

is there any free website that can convert my script into JSX so i can add it in my script pannel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 03, 2024 Dec 03, 2024

it's working with the method you suggested

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 03, 2024 Dec 03, 2024
LATEST

Maybe try this file downloader

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines