ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

layer spacing

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Brian Holzknecht
layer spacing
on Jan 22, 2019 at 7:40:51 pm

So I've asked this question a couple years ago, and unfortunately I only got one response and it didn't quite work for what I was trying to do. At the time I just did a work around and made it work, but now I'm hoping someone can help me with it again.

First off, I'm not very good with after effects expressions, but I do love the idea of being able to build little systems with them, so I spend a lot of time with trial and error and usually I'm able to figure things out, but this has got me stumped.

its basically a bar graph setup. My setup is 2 null object called "TR" & "BL" that defines the top left and bottom right area my layers stay in. Each bar layer is named "bar 1, bar 2, bar 3, etc...). Currently I can add any number of bars and they all stay within that area with even spacing between each, centered within the box. I would like to be able to add additional spacing between every 3rd, 4th or 5th... bar using a slider control. basically I would want to add two sliders one that defines how many bars should be in a group and one that adds this additional spacing.

I figured I needed to use the modulus operator in some way and probably a for loop to add the spacing to each layer, but honestly I'm completely stuck. The last time I posted this question the solution was to name the layers differently but that kind of defeats the purpose. the expression below is what I currently have on all my layers x position. Also maybe there is a more efficient/better way to do what I'm doing, but this is currently working for me. I'm pretty sure I have way too many parenthesis as well, but I haven't cleaned it up yet.

Thanks in advance

Brian Holzknecht

barNum = thisLayer.name.split("bar ")[1];
barTot= Math.floor(thisComp.layer("Layout").effect("number bars")("Slider"));
boxTR = thisComp.layer("TR").transform.position;
boxBL = thisComp.layer("BL").transform.position;
boxWidth = boxTR[0] - boxBL[0];
barWidth = thisComp.layer("Layout").effect("bar width")("Slider");
newSpace = boxWidth / (barTot-1);

(boxTR[0] + boxBL[0]) /2 + barNum*(newSpace-(barWidth/(barTot-1))) - (newSpace+(boxWidth*.5))+((barWidth/2)+(barWidth/(barTot-1)))


Return to posts index

Kalleheikki Kannisto
Re: layer spacing
on Jan 23, 2019 at 8:39:41 am
Last Edited By Kalleheikki Kannisto on Jan 23, 2019 at 8:49:18 am

Would be much easier to help you if it is possible to upload the file. Otherwise I would have to rebuild the project without any knowledge of what other expressions are in play, and the likelihood is high that I would just give you an answer that is unsuitable for other mechanics you have in the project.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Brian Holzknecht
Re: layer spacing
on Jan 23, 2019 at 8:24:57 pm

I'm not 100% sure how to share projects but here it is, I hope. I work on this project a little more each year, because I pretty much don't do any more after effects animations, but I have one client that still wants to use me once a year on a big project with a lot of bar graphs and charts, so I figured I might as well have some fun with it and try to automate a lot of it.

13053_basicbargraph2019.aep.zip

Thanks

Brian


Return to posts index


Brian Holzknecht
Re: layer spacing
on Jan 23, 2019 at 8:27:49 pm

Also all the expressions in my project may be terrible because I don't fully understand what I'm doing all the time, but they do seem to get the job done.

Thanks,

Brian


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]