Can Someone make a script that random shuffles selected layers In Z Space?
thanks in advance
Random Z position
Moderator: byronnash
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
-
- Posts: 47
- Joined: July 14th, 2008, 12:19 pm
- Location: The Netherlands
Yea Thats nice, But i want the selected layers to only shuffle in Z space
-
- Posts: 33
- Joined: February 7th, 2005, 7:32 am
- Contact:
this might work
or it might not (I just commented a few lines out + added other things)
I don't have AE at work.
or it might not (I just commented a few lines out + added other things)
I don't have AE at work.
Code: Select all
//
//
//3D Layer Distributor by Lloyd Alvarez (July 2006) http://aescripts.com
// fixed random function - feb2008
//
//
//Distributes layers in 3D space within set ranges..
//
//
//
//
var myComp = app.project.activeItem;
var safeToRun = true;
var myComp = app.project.activeItem;
if (myComp == null || !(myComp instanceof CompItem)) {
alert("A Comp must be active to run this script");
safeToRun = false;
}
if (safeToRun) {
clearOutput();
app.beginUndoGroup("3D Layer Distributor");
// Set Range parameters here: [min,max]
//var set_X = [-2500,2500];
//var set_Y = [-1000,1000];
var set_Z = [-12000,-2000];
var selectedLayers = myComp.selectedLayers;
for (var i = 0; i < selectedLayers.length; i++) {
var myLayer = selectedLayers[i];
//var x = 0;
//var y = 0;
var z = 0;
//x = set_X[0]// + (set_X[1]-set_X[0]) * Math.random() ;
//y = set_Y[0]// + (set_Y[1]-set_Y[0]) * Math.random() ;
z = set_Z[0] + (set_Z[1]-set_Z[0]) * Math.random() ;
var posArr = myLayer.property("Position");
myLayer.property("Position").setValue([posArr[0],posArr[1],z]);
}
writeLn("Distributed " + selectedLayers.length + " Layers");
app.endUndoGroup();
}
Boom boom boom.
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
actually, i think this might work better since it will base the shuffle on the existing position:
-Lloyd
Code: Select all
//
//
//3D Layer Distributor by Lloyd Alvarez (July 2006) http://aescripts.com
// fixed random function - feb2008
//
//
//Distributes layers in 3D space within set ranges..
//
//
//
//
var myComp = app.project.activeItem;
var safeToRun = true;
var myComp = app.project.activeItem;
if (myComp == null || !(myComp instanceof CompItem)) {
alert("A Comp must be active to run this script");
safeToRun = false;
}
if (safeToRun) {
clearOutput();
app.beginUndoGroup("3D Layer Distributor");
// Set Range parameters here: [min,max]
//var set_X = [-2500,2500];
//var set_Y = [-1000,1000];
var set_Z = [-12000,-2000];
var selectedLayers = myComp.selectedLayers;
for (var i = 0; i < selectedLayers.length; i++) {
var myLayer = selectedLayers[i];
//var x = 0;
//var y = 0;
var z = 0;
//x = set_X[0]// + (set_X[1]-set_X[0]) * Math.random() ;
//y = set_Y[0]// + (set_Y[1]-set_Y[0]) * Math.random() ;
z = set_Z[0] + (set_Z[1]-set_Z[0]) * Math.random() ;
var posArr = myLayer.property("Position");
myLayer.property("Position").setValue([posArr[0],posArr[1],posArr[2]+z]);
}
writeLn("Distributed " + selectedLayers.length + " Layers");
app.endUndoGroup();
}