3D Layer Distributer with Keyframing
Posted: January 22nd, 2009, 11:42 am
Hi, I am using this code, 3D Distributer on Z- Axis:
And I'm trying to get it to keyframe at the points I want it to change, and it's not allowing me it's something to do with Line 52:
Any ideas? Also if I wanted various scripts to add keyframes, what should I add, if there is a single solution?
Thanks
Dan
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 myVal = myLayer.property("Position").value;
myLayer.property("Position").setValueAtKey([myVal[0],myVal[1],z]);
}
writeLn("Distributed " + selectedLayers.length + " Layers");
app.endUndoGroup();
}
Code: Select all
myLayer.property("Position").setValue([myVal[0],myVal[1],z]);
Thanks
Dan