ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Finding the Global Scale Value of an object?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Darryl Torke
Finding the Global Scale Value of an object?
on Oct 3, 2012 at 3:48:52 am

I have a layer (result_layer) that uses the scale property of another layer for it's value. However, that secondary layer is a child of a parent that is scaled up by a few factors. When I use my expression all I get is the child's scale, not the true/global scale.

What I am trying to find out is the global scale property of the child layer. Is this possible in After Effects?

result_layer's scale expression (to which I only get the child's 'local' scale:
thisComp.layer("CHILD").transform.scale*.5;


Return to posts index

Dan Ebberts
Re: Finding the Global Scale Value of an object?
on Oct 3, 2012 at 6:12:40 am

Something like this:


L = thisComp.layer("CHILD");
s = L.transform.scale;
while (L.hasParent){
sp = L.parent.transform.scale;
s = [s[0]*sp[0],s[1]*sp[1]]/100;
L = L.parent;
}
s*.5;



Dan



Return to posts index

Darryl Torke
Re: Finding the Global Scale Value of an object?
on Oct 4, 2012 at 4:47:16 am

it worked! thank you


Return to posts index


Wouter Dijkstra
Re: Finding the Global Scale Value of an object?
on May 28, 2019 at 10:10:41 pm

I'm having the same sort of issue. I have a PreComp that is 2160x3680 and I put this in a smaller comp. Now parented this Precomp to a null, but now I'm not able to see how far I scale my PreComp. Since I don't want to go beyond the maximum resolution (scale > 100) I would like to have some kind of controller that will tell me when I reach 100.

Of course I could check this by unparenting my PreComp from the null, but is there a way where I can check the absolute/global scale value at all times even when it is parented to another layer and therefore relative data?


Return to posts index

Oleg Pirogov
Re: Finding the Global Scale Value of an object?
on May 29, 2019 at 1:52:51 am

This gives an absolute scale (in %) of parented layer:
L=thisComp.layer("CHILD_LAYER");
length(L.toWorld([1,0,0])-L.toWorld([0,0,0]))*100;


Return to posts index

Wouter Dijkstra
Re: Finding the Global Scale Value of an object?
on May 29, 2019 at 7:47:42 am

Hi Oleg,

For some reason it doesn't work the expression you gave me. You apply it to the "Scale" Property and Child layer?

This eventually turned out quite nicely. I don't understand the code, but it works:

s = scale[0];
L = thisLayer;
while (L.hasParent){
s = s*L.parent.scale[0]/100;
L = L.parent;
}
s


Return to posts index


Wouter Dijkstra
Re: Finding the Global Scale Value of an object?
on May 29, 2019 at 8:21:22 am

I might have cheered too soon.

It gives me an error:

expression result must be of dimension 2, not 1

Is this an easy fix?


Return to posts index

Tomas Bumbulevičius
Re: Finding the Global Scale Value of an object?
on May 29, 2019 at 8:51:28 am

Wouter, as easy as it could be, one of the easiest in fact, hehe!

Scales requires an array of 2 or 3 items. Just add retrieved value into array and you will be good to go.

[s,s]

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

Wouter Dijkstra
Re: Finding the Global Scale Value of an object?
on May 29, 2019 at 9:53:49 am

😉 I should have known. Thanks for clearing it up --> It works now.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]