Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Finding the Global Scale Value of an object?

  • Finding the Global Scale Value of an object?

  • Darryl Torke

    October 3, 2012 at 3:48 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;

  • Dan Ebberts

    October 3, 2012 at 6:12 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

  • Darryl Torke

    October 4, 2012 at 4:47 am

    it worked! thank you

  • Wouter Dijkstra

    May 28, 2019 at 10:10 pm

    I’m having the same sort of issue. I have a PreComp that is 2160×3680 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?

  • Oleg Pirogov

    May 29, 2019 at 1:52 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;

  • Wouter Dijkstra

    May 29, 2019 at 7:47 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

  • Wouter Dijkstra

    May 29, 2019 at 8:21 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?

  • Tomas Bumbulevičius

    May 29, 2019 at 8:51 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

  • Wouter Dijkstra

    May 29, 2019 at 9:53 am

    ???? I should have known. Thanks for clearing it up –> It works now.

Viewing 1 - 9 of 9 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy