• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Spacing an Array of Precomps?

Engaged ,
Dec 14, 2022 Dec 14, 2022

Copy link to clipboard

Copied

Hi Everybody, I have a situation where I'm putting together a poster wall similar to the attached image.

 

I have portrait and landscape images lined up in stacked rows and they all need to be evenlly spaced. So I would like to use null objects or something to where I can use a controller and space them all accordingly. Especially if my boss is like "can you bring them all closer together". I don't want to do that all one by one (nightmare)

 

So, does anybody know of any tutorials or quick demos that show how appraoched/created? I have an idea of what need tos happen but I'm not entirely sure how to stick it all together.

 

Any feedback highly appreciated. Thanks for reading!

 

TOPICS
Expressions , How to

Views

327

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 14, 2022 Dec 14, 2022

The math is easy enough. It's always just width/ height + padding - anchor point position. As Rick already pointed out, the real trick is to simply have a strategy in building the strips/ columns in pre-comps and then combining them in a parent comp. So assuming you build your image strips in a pre-comp, the positioning would always be:

 

xPad=comp("Master").layer("Controller").effect("Padding X")(1);

if (index != 1)
{
xRef=thisComp.layer(index-1);
xWid=xRef.width;
xPos=xRef.transform.position[
...

Votes

Translate

Translate
Community Expert ,
Dec 14, 2022 Dec 14, 2022

Copy link to clipboard

Copied

More details would be helpful. Are all your images the same height (or have they already been scaled to be the same height)? Are they already placed in rows? If not, how wide is the poster wall? Plus any other relevent info about how you have things set up would help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 14, 2022 Dec 14, 2022

Copy link to clipboard

Copied

Pre-planning is the secret. Build your Horizontal and vertical image grid, arrange layers in order based on the grid, then add a simple expression that looks at the layer above to drive position. If the grid is one horizontal, two vertical, 2 horizontal, then 1 vertical on the first row, then two verticals, skip the two vertical images on the row above. Two vertical, and one horizontal, you should be able to figure out the sequencing order for the expression. Then add a couple of sliders for horizontal and vertical padding on a controller null.

 

If all the layers are 3D, then you don't have to worry about keeping everything in the comp boundary. Just collapse transformations. The trick is knowing what size each of the layers or the nested comps are and what your grid looks like, then stacking the layers in the same order that they are in the grid so you can use index - 1 instead of the layer name to offset the position of each layer. 

 

I don't have time to build a sample for you, but I've created this type of image grid layout before. It doesn't take much once you have designed the grid. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 14, 2022 Dec 14, 2022

Copy link to clipboard

Copied

The math is easy enough. It's always just width/ height + padding - anchor point position. As Rick already pointed out, the real trick is to simply have a strategy in building the strips/ columns in pre-comps and then combining them in a parent comp. So assuming you build your image strips in a pre-comp, the positioning would always be:

 

xPad=comp("Master").layer("Controller").effect("Padding X")(1);

if (index != 1)
{
xRef=thisComp.layer(index-1);
xWid=xRef.width;
xPos=xRef.transform.position[0];
xAnc=xRef.transform.anchorPoint[0];

mWid=thisLayer.width;
mAnc=thisLayer.transform.anchorPoint[0];

X=xPos+xWid-xAnc+mWid-xAnc+xPad;
}
else
{
X=value[0]
}

[X,value[1]]

The same appliues to combining the strips. You only substitute width with height. Of course you need to create all the sliders and prep your images accordingly.

 

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 15, 2022 Dec 15, 2022

Copy link to clipboard

Copied

Hi guys,

 

It sounds like I need to do some more study on controller theory. Once I have that and a basic understanding of the mechanics and syntax for making something go (e.g. up/down) based on a slider, then use that syntax/structure to affect the padding (width + x-padding amount, or y-padding if it's the parent controlling the rows). I'm dealing with same height, two widths (portrait and landscape, just like the attached image), but I guess as long as I can reference the width of the objects and assign them variable values then it doesn't matter. 

 

Thanks for the feedback guys, it mos def helps with perspective on approach.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 15, 2022 Dec 15, 2022

Copy link to clipboard

Copied

I started on some code to automate the horizontal spacing of layers. The expression is incomplete and only accounts for the first row. It uses sourceRectAtTime, compensates for scale, gives you the opportunity to add a control slider to adjust horizontal, and in a improved revision, vertical spacing so that every 5 (or the number of layers you choose) would drop down vertically and complete the layer grid. Mylenium's expression works fine for layers that are the same size. This expression works for layers with different sizes and scales. It could even be easily modified to work with shape or text layers. 

 

Here you go:

 

xPad = 20;// add a link to your X Padding Slider control on a Null or Guide layer
yPad = 20;// add another slider for Y
s = scale * .01;
i = index;
if (i == 1)
	value;
else{
	tLyr = sourceRectAtTime();
	lW = s[0] * tLyr.width/2;
	lH = tLyr.height/2;
	ref = thisComp.layer(i - 1);
	rScl = ref.scale * .01;
	refBox = ref.sourceRectAtTime();
	refW = rScl[0] * refBox.width / 2;
	refH = refBox.height / 2;
	x = refW + xPad;
	y = refH + yPad;
	ref.position + [x + lW, 0];
}

 

I don't have time to add the additional if() arguments to stack the layers vertically. Maybe Dan Ebberts could jump in and complete the code or point us to a more interesting workflow if I don't have time to complete the expression.

RickGerard_0-1671142447522.gif

Good luck with your project

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 15, 2022 Dec 15, 2022

Copy link to clipboard

Copied

Hi Rick, thanks so much for taking the to put together that demonstration. That's exactly what I'm trying to do. Unfortunately, I think I found my problem. SourceRectAtTime only works with shape/txt layers. It doesn't work with precomps or images. I've been all over the web and that seems to be the concensus of all tutorials and guides. 

 

I think that's that. I'll try to go over Myllenium's script and see if I can' stitch togheter some referencing.

Thanks again. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 15, 2022 Dec 15, 2022

Copy link to clipboard

Copied

SourceRectAtTime works for layer size. If you are using pre-comps, you can either size the pre-comp or find the size of the layer inside the nested comp. The only part of sourceRectAtTime() that does not return a value on a footage layer, nested comp, or solid layer is left and top. I use it instead of width because width does not work with Text or Shape layers. That sample comp was all different-sized solids, some of them scaled. 

 

If you wanted to find the size of a layer inside a Pre-comp named Grid 1, you would change the ref description from ref = thisComp(index-1) to ref = comp("Grid 1").layer("layer name")

 

My approach would be to create each image you want to fill the grid at a frame size that would have them very close to 100% scale in the final comp at some point in the timeline and not pre-compose. 

 

If the grid is to be full of animated layers, then I would create the Comps at the same size that I would use for the images. For example, if your main comp was 4K and the closest you would ever get to a layer would be 3 layers in a row, then the size of the nested comp or the image would be the Comp width divided by 3 (rounded to even numbers) or 3840 / 3 = 1280 pixels wide. That's how you would prepare for a project like the one that you describe. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 16, 2022 Dec 16, 2022

Copy link to clipboard

Copied

LATEST

Hi Rick, thanks so much the explanation.  sourceRectAtTime() looks like a very useful function it looks like from more expression hunting that I've done that Width/Height vars goes in the position layer transform attriubte. That's what I've been trying to figure out as the placement doesn't seem all that intuitive when there's no size attribute.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines