-
script to swap the positions of n layers?
hello!
I have a small issue with a need, but I don’t quite know which of these two options would be more efficient.
I have a series of layers (which may vary and which are actually comps) . Each one is in a fixed position. I need that with each execution of a script, the layers change between their positions, randomly and without repetitions.
As possibility A, a script that makes random swap between positions given a number n of layers.
As possibility B, to randomly replace each layer by selecting the layers and at the same time the compositions in the bin, making a multiple and random replacement on each script execution
Exploring the possibilities of option A, I have found this script https://gist.github.com/ff6347/3468163 that works perfectly between 2 layers, but I don’t know how to adapt it to work on a selection of layers.
That script says:var layers = app.project.activeItem.selectedLayers;
var pos1, pos2; for (var i = 0; i < 2; i++){ if(i ==0) pos1 = layers[i].position.value; if(i ==1) pos2 = layers[i].position.value; // layers[i].position.selected = true; }; layers[0].position.setValue(pos2); layers[1].position.setValue(pos1);
If anyone can shed some light I would greatly appreciate it.
Surely if I had done it by hand I would have finished by now and in less time invested than doing fruitless tests, but anything to learn something new!