Align irregular layers to a grid with padding

Explorer ,
Jun 26, 2022 Jun 26, 2022

Copy link to clipboard

Copied

Hello,

 

I have layers of varying dimensions (160x600 1080x1080 320x250 480x320 728x90) roughly between 80 to 100 layers.

 

Is there a way to have these layers populate into a grid with even padding around each layer, attached is an example.

 

I'd rather not use expressions as I'm sure it will bog AE down;  it it doesn’t have to be created in After Effects. It could be done in InDesign, Illustrator, or Photoshop and once in AE replace these placeholder layers with my comped layers.

 

I've had a Google, but the only real solution appear for CSS and website design. I'm here to ask if someone has seen or used such a grid layout before.

 

Thank you

TOPICS
Expressions , Resources

Views

175

Likes

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

Adobe Community Professional , Jun 27, 2022 Jun 27, 2022

Collage from Motion Boutique does the job - https://www.motionboutique.com/collage/

Likes

Translate

Translate
Adobe Community Professional ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

Collage from Motion Boutique does the job - https://www.motionboutique.com/collage/

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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
Explorer ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

 

Thank you - I have grabbed that in the past but now on the latest version of AE it comes up with numerous errors and doesn't execute the script. 

 

But yes, that would be perfect.

Likes

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
Adobe Community Professional ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

I've just checked and it works fine with the latest AE - V22.5

Ensure you are using AE's Javascript Engine - see image below

RolandKahlenberg_0-1656317331803.png

And if this doesn't help, what exactly are the error messages you receive when applying Collage?

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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
Adobe Community Professional ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

Even when I'm set to the Legacy/Extendscript Expression Engine, Collage works fine.
So - what error messages are you receiving? 

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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
Explorer ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

 

Thank you Roland - first thing I did was to check both engines just in case.

 

If I run it via file > scripts I get "Unable to execute scipt at line 2835. Object of type Function found where a Number, Array, or Property is needed"

 

If I install and run through KBAR, I skip that first error and get "ReferenceError: Function numeric.svd is undefined" and "no solution found!"

Likes

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
Adobe Community Professional ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

I run it through the Windows Menu and just tried it via File>RunScript and no issues. 

Is your AE Prefs under scripting set up to allow Network access - see image below

RolandKahlenberg_0-1656319467731.png


And which version of AE and OS are you on?

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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
Explorer ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

 

Thank you Roland, I appreciate you're help.

 

Yes, that's ticked and I'm on macOS 12.4 and AE 22.5.0

Likes

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
Explorer ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

*your

Likes

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
Adobe Community Professional ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

It's most likely a kBar thing or MacOS or both. I would try disabling Kbar since it's the easiest to disable/uninstall. Sorry, I can't assist you more but do report back and maybe something does pop up in my head, I'll share it here. Good Luck.


Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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
Explorer ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

 

I got it working by closing all scripts and then it could run. Unfortunatly, it's not quite what I'm after as it resizes each layer to fit. Thank you though.

Likes

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
Adobe Community Professional ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

Don't discount using expressions. You can get any layer size using sourceRectAtTime() or thisLayer.size.

By default, the Anchor Point is always at the layer's center. To distribute layers in a grid, you must know how wide the biggest layer is and then set up a multiplier based on the layer's index. 

 

I don't have time to fiddle with a grid, but here's an expression that offsets layers in Y every 800 pixels starting with the position of a null layer on top of the stack.

 

 

ref = thisComp.layer("Null 1");
ofstNo = ref.index + 1 - index;
grid = [800, 800] / 2; // pad + 1/2 the size of largest layer
ref.position + [0, - ofstNo * grid[1]]

 

 

It won't take much to take this starting point and set up a grid that is 10 X 15 and has all layers below lined up without doing anything else. You can then animate the position of the Null to move the entire grid around. 

 

This stacks different-sized layers up in Y with 20 pixels between them;

 

ref = thisComp.layer(index - 1);
lyrHeight = height/2 + 20; // 20 pixel padding
newY = ref.position[1] + ref.height/2 + lyrHeight;
[ref.position[0], newY]

 

Likes

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
Explorer ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

LATEST

 

Thank you - I'm going to have a play with this and I'm sure I'll find some new uses out of it.

Likes

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
Adobe Community Professional ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

In your example, there are four layer sizes and the sizes have a very specific relationship to each other. For example, if the small squares are 100x100 and the gap between is 15, the rectangles have to be 100x215 (or 215x100) and the large squares would have to be 215x215. Unless your layer sizes are related like that (and it doesn't appear that they are), there's no algortihm that can assemble such a grid without scaling (and probably non-uniform scaling) the layers.

Likes

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
Explorer ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

 

Thank you - I just found with no finate control over the scaling, layers became 3% of their original size to fit. I'll have to create one manually in illustrator and import and swap out.

Likes

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