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.
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.
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...
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;
}
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;
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? ..
Copy link to clipboard
Copied
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.