Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: HomeForumBasicsExpressionsTutorialsPodcastsMotion GraphicsTrainingCinema 4DFAQ

Distributing 3D layers in one axis ?

Cow Forums : Adobe After Effects

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>
Distributing 3D layers in one axis ?
by rimantas lukavicius on Aug 27, 2008 at 10:19:24 am

Hello,

This script creates random positions to 3D layers and it works well.
But I need to distribute 3D layers only in z axis while keeping x
and y positions as they are. Could someone help me?

(sorry for posting whole script)

//
//
//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() ;


myLayer.property("Position").setValue([x,y,z]);



}
writeLn("Distributed " + selectedLayers.length + " Layers");
app.endUndoGroup();
}

Respond to this post   •   Return to posts index

Re: Distributing 3D layers in one axis ?
by Dan Ebberts on Aug 27, 2008 at 2:34:10 pm

Probably the simplest way would be to replace this line:

myLayer.property("Position").setValue([x,y,z]);


with this:

var myVal = myLayer.property("Position").value;
myLayer.property("Position").setValue([myVal[0],myVal[1],z]);



Dan



Respond to this post   •   Return to posts index

Re: Distributing 3D layers in one axis ?
by rimantas lukavicius on Aug 27, 2008 at 2:43:28 pm

Hey Dan,

This is what I looked for. Thank you very much!

Best regards,
Rimantas

Respond to this post   •   Return to posts index

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>


FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]