Activity › Forums › Adobe After Effects Expressions › Maintain space between objects
-
Maintain space between objects
Posted by Trent Diggity on October 19, 2010 at 7:15 pmHey Guys,
I’m looking for help with an expression that will help keep the space between objects.
Heres the situation.i’ve got a row of boxes
i want to maintain the distance between those boxes
each will scale up and then back down as the effect moves down the line.
I’d like to keep the white space that is between those boxes the same.make sense?
Bryan Woods replied 13 years, 5 months ago 4 Members · 9 Replies -
9 Replies
-
Dan Ebberts
October 19, 2010 at 7:45 pmI think this works. It assumes that all layers are participating, that they all start at 100%, and that they are arranged left to right, with the left-most being the layer at the top of the layer stack (in the Timeline panel) and the right-most being at the bottom.
accum = 0;
for (i = 1; i <= thisComp.numLayers; i++){
L = thisComp.layer(i);
if (i < index) accum += ( L.transform.scale[0]/100 - 1)*L.width/2
if (i > index) accum += ( 1 - L.transform.scale[0]/100)*L.width/2
}value + [accum,0]
Dan
-
Trent Diggity
October 19, 2010 at 10:10 pmHey Dan,
Thanks a ton. It seems to be working for the most part but a few layers are giving me some issues, im gonna try trouble shooting in a bit. I’ll let you know how it turns out. -
Dan Ebberts
October 19, 2010 at 10:26 pmSure. There are lots of ways. If the layers of interest are contiguous numbers, you can just limit the search to that range. If there are layers sprinkled throughout the stack that you want to ignore you can check for them specifically in the loop and skip them.
Dan
-
Riccardo Sinti
February 1, 2011 at 10:49 pmI’ve applied this expression to my stack of layers. They are all bunched up at the cent of the comp but I want them to start from the left. Any way to justify this line of boxes either left or right?
ThanksThank You
-
Dan Ebberts
February 1, 2011 at 11:23 pmThis should line everything up with the left edge of the comp:
x = 0;
for (i = 1; i < index; i++){
L = thisComp.layer(i);
x += (L.transform.scale[0]/100)*L.width;
}
x += (transform.scale[0]/100)*width/2;
[x,value[1]]Dan
-
Riccardo Sinti
February 7, 2011 at 5:02 pmThanks for this expression. How would I adjust the space between layers though? After applying this expression my layers started to overlap when I wish to have a little space between each one.
Thanks Again!Thank You
-
Dan Ebberts
February 8, 2011 at 1:38 amThis should work:
x = 0;
gap = 10;
for (i = 1; i < index; i++){
L = thisComp.layer(i);
x += (L.transform.scale[0]/100)*L.width + gap;
}
x += (transform.scale[0]/100)*width/2;
[x,value[1]]
Dan
-
Bryan Woods
December 4, 2012 at 5:52 pmHey Dan, I came across this while working on the script you helped out with for resizing layers based on alpha. I think this is the last piece of the puzzle for me, and I’m trying to figure out how to use this code to align to center and not the left edge. I see x=0 which I understand is 0 on x axis so that is the edge, and adjusting it does shift everything over, however I’m trying to figure out how to get the logos to shift from center. So 1 logo would be center, two logos would be next to each other, three would be one center and one on either side, etc.
Reply to this Discussion! Login or Sign Up