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

How to get the stretch% of a layer with an expression

Explorer ,
May 09, 2021 May 09, 2021

Copy link to clipboard

Copied

I want to know how to get the stretch% of a layer with an expression
With Script

app.project.item (index) .layer (index) .stretch


It seems that you can read and write with
Writing with an expression will result in an error.
If you know, please let me know.

TOPICS
Expressions , Scripting

Views

885

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

Explorer , May 18, 2021 May 18, 2021

How to get the stretch value of the layer with the expression, I solved it myself, so I will post it for the time being.
It's a bit of a hassle, but it's also a way to get the stretch value by placing a marker at the outTime position where there is no direct way to get it.

image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Votes

Translate

Translate
Community Beginner ,
May 09, 2021 May 09, 2021

Copy link to clipboard

Copied

emm.. It's seems like cannot get "stretch" value directly,

I can only get video footage "stretch" value,

var l = thisComp.layer(2);
var stretchValue = l.outPoint / l.source.duration;

 

But this will be error with solid layer、image layer and so on which ".source.duration == 0"....

I can't find any other ways to get strech value...

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 ,
May 10, 2021 May 10, 2021

Copy link to clipboard

Copied

Sounds like a good workaround! You could handle layers with source.duration == 0 in an if/else

 

if(l.source.duration ==0) {
   // layer cannot be stretched
   stretchValue = 1;
}
else {
   stretchValue = l.outPoint /l.source.duration;
}
Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

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 Beginner ,
May 10, 2021 May 10, 2021

Copy link to clipboard

Copied

Emm.. I think this way will be better:

we can't set `stretchValue = 1` when `source.duration == 0` because designer will change this value within an solid layer.

we should define an variable called `defaultOutPoint`, it's value equals to an layer (such as solid, or image layer) `outPoint` value when stretch set to 100%;

then ,

stretchValue = l.outPoint / defaultOutPoint.

like this:

var l = thisComp.layer(2);
var defauleOutPoint = l.source.duration;

if (defauleOutPoint == 0) {
    // set this value manually
    defauleOutPoint = 3.36;
}

l.outPoint / defauleOutPoint;

 

code.png

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
Explorer ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Thank you for your advice.
I got a little better understanding.
What I found out this time
Just as I can't read the Stretch value of a layer directly in an expression
There is no way to get the value of Duration too.
Even though there is startTime, it seems that there is no way to get the value of outTime.

Since there is no way to get the outTime of the layer, if I substitute outPoint,
If I was editing outPoint, it would lead to not being able to get the intended Stretch value.

This is an annoying problem.
Is it an Adobe official function improvement consultation 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
Explorer ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

LATEST

How to get the stretch value of the layer with the expression, I solved it myself, so I will post it for the time being.
It's a bit of a hassle, but it's also a way to get the stretch value by placing a marker at the outTime position where there is no direct way to get it.

image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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