Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Generate an x,y,z position for 100 layers

  • Generate an x,y,z position for 100 layers

    Posted by Kevin Church on March 10, 2010 at 10:37 pm

    I am looking for a way to generate an x,y,z position for 100 layers that remains constant through time. I have a pile of pictures that I want to place in different positions in 3D space without having to manually set the positions.

    I used the expression below, but the values are randomized each frame.

    Thanks in advance for any help!

    maxZ = 5000;
    minZ = -5000;
    maxX = 3000;
    minX = -3000;
    maxY = 2000;
    minY = -2000;

    z = random(minZ,maxZ);
    x = random(minX,maxX);
    y = random(minY,maxY);

    [x,y,z]

    Kevin Church replied 16 years, 2 months ago 4 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    March 10, 2010 at 11:30 pm

    just add this at the top:

    seedRandom(index,true);

    Dan

  • Kevin Church

    March 10, 2010 at 11:41 pm

    Thanks Dan,

    I am new to After Effects and new there would be an easy solution. Just so I understand, the true part is what makes this not sensitive to time?

    Cheers,
    Kevin

  • Dan Ebberts

    March 11, 2010 at 12:04 am

    Yes, that’s correct.

    Dan

  • Kevin Church

    March 11, 2010 at 12:32 am

    Thanks so much!

  • Darby Edelen

    March 11, 2010 at 1:27 am

    Dan’s already got your back on seedRandom(index, true); but I thought I’d also mention that random(); will accept a pair of vectors/arrays, so you could simplify your code to:


    seedRandom(index, true);
    min = [-3000, -2000, -5000];
    max = [3000, 2000, 5000];

    random(min, max);

    Darby Edelen

  • Lloyd Alvarez

    March 11, 2010 at 1:38 pm

    Using expressions is not the most efficient way to do this since expressions are evaluated for every
    layer at every frame. This is why I wrote a script to do this. The script only
    needs to he evaluated once at run time. https://aescripts.com/3d-layer-distributor/

    Lloyd

    https://aescripts.com

  • Kevin Church

    March 11, 2010 at 6:56 pm

    cool, thanks for the tip! That code is much cleaner.

    Lloyd, I am not too familiar with scripts but I like the theory. I’ll take a look at your link.

    Thanks everyone!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy