Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Parent child linking – applying correct scale.

  • Parent child linking – applying correct scale.

    Posted by Richie Tovell on December 17, 2009 at 7:34 am

    Hi.

    I need to tweak this expression a little

    L = thisLayer;
    s = transform.scale.value;
    while (L.hasParent){
    L = L.parent;
    for (i = 0; i < s.length; i++) s[i] *= 100/L.transform.scale.value[i] } s This disables the scaling behaviour between parent/child layers (many thanks Dan for this excellent expression) I'm unfortunately still going to need to retain control over each layers scale independently of it's parenting, can this expression be tweeted to still allow for control of scale from a null object? I'm using a nulls y rotation as the controller. which looks like this. temp = thisComp.layer("Null 2").transform.yRotation; [temp+100, 100, temp+100] Dan? as this was your brain child perhaps you could help me a little further? you know the layers I'm using are parented, we've basically stopped them from carrying out this accumulative scaling behaviour (where one layer scales by the value of all the parented layers in the stack before it) now I need to give each of the free layers the correct scaling information that they do need, without effecting the scales of the other parented layers in the stack. Does that make sense? Coda - musical selections; in film, the ending or last section of a film (often wordless).

    Steve Hardie replied 10 years, 4 months ago 3 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    December 17, 2009 at 9:04 am

    Try this:

    L = thisLayer;
    temp = thisComp.layer(“Null 2”).transform.yRotation;
    s = [temp+100, 100, temp+100] ;
    while (L.hasParent){
    L = L.parent;
    for (i = 0; i < s.length; i++) s[i] *= 100/L.transform.scale.value[i] } s Dan

  • Richie Tovell

    December 17, 2009 at 11:09 am

    It works beautifully.

    I’m going to post this once it’s finished, it’s going to be legendary 🙂

    Thanks Dan!

    Coda – musical selections; in film, the ending or last section of a film (often wordless).

  • Steve Hardie

    January 12, 2016 at 5:04 am

    does this work regardless of how many parent child relationships there are?
    I have 3 nulls, the first two of which i want to scale but the third (last) in the chain needs the independent scale ( will move and reposition with the others but not scale) I tried the expression in the last child with this error “invalid numeric result (divide by zero?)”

  • Dan Ebberts

    January 12, 2016 at 6:54 am

    The original expression should work for what you’re doing:


    L = thisLayer;
    s = transform.scale.value;
    while (L.hasParent){
    L = L.parent;
    for (i = 0; i < s.length; i++) s[i] *= 100/L.transform.scale.value[i];
    }
    s

  • Steve Hardie

    January 12, 2016 at 9:00 am

    Thanks so much for your help.
    If i make a new comp and apply this script it works great.
    When I apply the script in my project it doesnt (see image) it returns an error, is there some other protocol I should follow when dealing with a project with multiple nulls?

  • Dan Ebberts

    January 12, 2016 at 2:43 pm

    The expression will die if any of the scale value of any of the layers in the chain is zero. Could that be happening in your project?

    Dan

  • Steve Hardie

    January 12, 2016 at 5:12 pm

    Dan, “you are the man”, you must have a crystal ball over there. That is indeed the issue as to why it wouldn’t work.
    I have to zero one of the nulls that rotae within a rotaion of another to make the particles scribe a circle and not a looping motion, but perhaps if I scale to 1 or a fraction, the expression will work, or at least be imperceptable?
    Thanks, I shall have to visit your tip jar!

  • Steve Hardie

    January 12, 2016 at 5:23 pm

    Also the image I had sent was the wrong one. (attached correct here)
    Could the expression work with a -1 so that the use of 0 would work? otherwise I will do as I said previously and only reduce scale to 1 and not zero and hope it is not noticeable.

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