1 slider to proportionately distribute layers in z-space
From ‘Mastering 3d Cameras in After Effects’ by Jayse Hansen
Class Preview at Post Production World Israel, Nov. 2007
Here is the code that Dan Ebberts wrote that I demonstrated in class for spreading out 3d layers proportionately using one slider control. (Thanks be to Dan!)
Basically the steps are:
- Import your psd in layers, or create a bunch of solids as I did in the example above.
- Turn them all 3d
- Add a null, apply Effects>Expression Controls>Slider (make sure this null is named ‘null1′ In other words - just don’t rename it.)
- In the Position Property of each 3d layer, add an expression by alt/opt clicking the Position StopWatch and pasting the following code:
position+[0,0,(index-1)*this_comp.layer("Null 1").effect
("Slider Control").param("Slider")]
- Set your view to a side view (Right or Left)
- Drag the slider on ‘Null 1′ and watch your layers spread like magic.
Here’s a sample After Effects Project FileSome notes:
You may find that your layers look larger as they move in z space towards you. A quick fix would be parenting all the 3d layers to a null and scaling it down.
If you need more precision and want to scale and separate at the same time so that the layers appear to remain the same size even while being moved in z-space, (very useful!) check out Zax’s excellent new plug in ‘Z-Distribution‘ in the Layer Tools set.
Hope that helps,
// jayse
Share It!Filed under: After Effects on December 3rd, 2007

I was in this class and you showed amazing ways to work. Thank you so much for taking the time to share your workflow and sharing these files and explaining how to use the codes.
Will try this one out!
Orki
Just tried it - works perfect! That’s so cool - thanks!
now I understood how you did it. a million thanks!
I cant wait for your new training video! how much? will buy it no matter what the cost as I’m sure it’s worth it and more!
was looking for a way of doing this! As always great stuff here. Thanks!
The expression keeps having an error. It says there is a syntax error at line 1. I have shape layers that I am trying to use this effect on; however, I am having trouble with even solid layers too. When I apply the expression to the layer an error dialog pops up.
people getting an error you need to replace the quotes, often blogging software replaces ” with “ and ” they look the same at small sizes but will cause errors when copied/pasted.
Really wish bloggers would realise this
Good call Terry - fixed!
thanks for sharing this, great idea, doing an aiport runway at night type vibe and this is going to save me loads of time.
one thing though, applying the expression one by one could take forever in some cases (i need around 200 lights for example), so what you can do is apply it to your first layer, then with the position property selected go to Edit> Copy Expression Only. Then just select all, apart from your null, and paste.
Your write is motivation that i can learn more about this topic. I have to acknowledge your clarity broadened my sentiments and I’ll instantly take your rss feed to stay updated on any coming posts you might publish. You deserve gives thanks for a job well done!
I think it was going to be some boring old posting, but it really compensated for my time. I’ll post a web link to this post on my blog. I am sure my readers will find that very useful.
Great post, bookmarked your site, will be back later.