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

Several length operations to shape layers - possible?

Participant ,
Sep 05, 2022 Sep 05, 2022

Copy link to clipboard

Copied

Hi, 

 

trying to achieve a setup where one layer ("Distance") make up the distance to several shape layers using the length function. I'm getting there but running into a couple of situations:

 

1.  I'm trying to have several layers be affected by each other - not going great. Is this a limitation of how the Expression system is constructed where each code runs in sequence?

2. Each time I add more than one length function on one layer the results is not what I'm expecting. Is this a limitation? 

 

I'm attaching a scene file with this test setup. 

Basically what I want to achieve is for each layer to increase in size[0] when the Distance layer is close and for it to affect all the other surrounding layers. 

 

Best

/M

 

TOPICS
Expressions , How to , Scripting

Views

312

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
Participant ,
Sep 05, 2022 Sep 05, 2022

Copy link to clipboard

Copied

Oh, another thing I can't fully understand is that sometimes the selected shape of the shape layer differs from rendered shape. I'm guessing this has to do with the order of how this is executed but can't fully understand it. 

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
Valorous Hero ,
Sep 05, 2022 Sep 05, 2022

Copy link to clipboard

Copied

See if this tutorial on using Expressions to create a proximity effect helps - https://youtu.be/eEEd-YuBHn0


Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

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
Participant ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

Thanks!! I'll look into that

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
Participant ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

This is more or less exactly how I've set it up. Unfortunately no insight on how I can combine several length() functions at the same time. 

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
LEGEND ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

In their simplest form you simply add them and then normalize them to a reference measure (fixed value, shortest distance, longest distance, average distance etc.) - whatever you fancy. A sketch and some text explaining what you actually want to happen would certainly be helpful.

 

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
Participant ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

Thanks for the explanation. 

Do you have an example of how to normalize several length values to a reference measure? 

 

Attaching a screenshot describing what I'm trying to achieve. 

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 ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

Unless you would allow the objects to overlap, this would not work by calculating the lengths nor is it necessary. Based on your sketch it appears you more want to always calculate the distance to a specific reference point and then just have the squares scale accordingly, honoring the gaps. This can easily be set up by adding a Null e.g. at the left edge, then measuring the length only on the X axis and piping everything through some linear() functions. All that matters than is to correctly reference the start values/ start sizes of the rectangles. Here's something that should work:

 

mAnchor=thisComp.layer("Null").transform.position;
mMover=thisComp.layer("Dot").transform.position;

mDist=length([mAnchor[0],0],[mMover[0],0]);

dStart=0; //minimum distance
dEnd=500; //maximum distance
wStart=0; //minimum rectangle width
wEnd=500; //maximum rectangle width

linear(mDist,dStart,dEnd,wStart,wEnd);

 

This would be applied to the scale/ rectangle path width of the first rectangle and you'd apply similar code to the other ones as well. Once that works, you can simply reference the width of the rectangles and calculate their positions relative to each other with simple additions/ subtractions and also of course simply subtract the gap.

 

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
Participant ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

This looks very much as my current setup. I was probably a bit vague - right now I have everything working so far as the layers are getting their scale widht from the distance to the Distance layer using the length function, and I'm running those values through linear to get the correct size. 

 

What's causing the problem is your last paragraph about referencing the width of the other rectangels and calculating the width based on them. When I introduce that equation I can't figure out in what order to do it. 

 

Attaching a recording of the current behavior. 

 

 

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 ,
Sep 05, 2022 Sep 05, 2022

Copy link to clipboard

Copied

This is not a limitation of expressions or for that matter JavaScript, you simply need to smarten up your code. Of course just measuring the linear distance with multiple objects will produce ambiguous situations simply because the distances may eventually be the same and yes, of course if you just slap on one such calculation after the other one result may override the other. You have to do your research and use more advanced math and algorithms. And please do everyone a favor and provide the actual code and screenshots, not projects. Not everyone has time or will to open projects and the version messinesss will simply make it impossible to look at your project if people use older versions.

 

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
Participant ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

🫣

yeah, researching is exactly what I'm trying to do here. Thanks for not pointing me in any useful direction, real helpful. 

Noted about attached .aep 

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 ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

Here's a possible solution to your issue:

 

Responsive Rectangles.png

 

Since it would take too long to explain all the details, I've created a project (CS6) and attached it here. You can add as many rectangles as you like. You only need to adapt the references to the previous rectangle in the expressions and play with the values. Check the Controller. There are some options there for the gaps and scaling and the "Mover" is what drives the animation as it passes across the rectangles.

 

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
Participant ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

LATEST

Thank you a lot for the brain power on this one. 

Although this is very close to the existing setup I already have. 

 

 

 

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