FORUMS: list search recent posts

Position layers in groups

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Brian Holzknecht
Position layers in groups
on Feb 8, 2016 at 6:37:16 pm

I'm trying to setup a system for some bar graphs I need to animate. I have everything done but I'm looking to add another option to help streamline my setup, but I'm not sure how. Basically I have the following position expression on all my layers, which allows me to keep the number of bars I have centered on the screen and controls the spacing between each one. Ideally I would like to add 2 additional slider controls, one that allows me to choose the number of groups and another that allows me to adjust spacing of the bars in the group. So instead of having multiple single bars spaced evenly I can have something like 3 bars spaced closely together then a bigger space then 3 more bars and so on. Like this. And hopefully the same expression can go be used on each layer so I don't have to modify the layers depending on the set up.

||| ||| ||| ||| or like |||| |||| |||| or || || || || ||

Thanks,

Brian Holzknecht

y = value[1];

barNum = thisLayer.name.split("bar ")[1];
spacing = thisComp.layer("Layout").effect("Spacing")("Slider");
barTot= Math.floor(thisComp.layer("Layout").effect("number bars")("Slider"));
compCenter = thisComp.width/2+(barNum*spacing);

[compCenter-(spacing*(barTot/2))-(spacing/2), y]


Return to posts index

Miguel de Mendoza
Re: Position layers in groups
on Feb 9, 2016 at 11:20:44 am

What you must do is to add a multiplier for each bar and group. Let's say you have group 1, group 2 and group 3. Name each bar like this "bar_1_1", "bar_2_1", "bar_1_2", etc... (first number for bar number and second for group number. Now you have to do two things: get the multipliers for each bar, and add two slider controls to your "Layout" layer: "bar_separation", "group_separation". Now you can write this:

barSpacing = thisComp.layer("Layout").effect("bar_spacing")("Slider");
groupSpacing = thisComp.layer("Layout").effect("group_spacing")("Slider");

multipliers = name.split("_");
barNum = multipliers[1];
groupNum = multipliers[2];

spacing = (barSpacing * barNum) + (groupSpacing * groupNum);
//.... the rest of your code.


Return to posts index

Brian Holzknecht
Re: Position layers in groups
on Feb 11, 2016 at 12:38:52 am

Thanks Miguel. I was finally able to check it out. Is there an easy way to do this without changing name of layers? I assume that would require conditional statements. I would like to use another slider to control the grouping. For instance, if there are 6 bars total, and the slider control is set to 3 then it would be 2 groups of 3.

This may not be possible without either writing a specific expression for the layers that need to be grouped, or by the way you wrote it. I thought somehow using the modulus operator to determine the bar number where the separation would happen, but wasn't sure how to effect the other corresponding bars.

If you have any other ideas that would be awesome.

Thanks,

Brian


Return to posts index

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