Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions An expression that worked fine in CS4 no longer works in CS5

  • An expression that worked fine in CS4 no longer works in CS5

    Posted by David Cabestany on March 26, 2011 at 4:20 pm

    Hi all,

    I have an old project created in AE CS4, with the following expression in the source text field at one text layer:

    (“z=” +(comp(“Camera+Light”).layer(“bullet”).transform.position[0]))

    Pretty much it returns a visual reading of my x position preceded by “z=” on it, it reads something like:

    z=12.4875698245 at any given frame.

    Now I’m trying the same structure in a completely different project, now in CS5, the expression I’m trying to use is this one:

    (“rot=”) + thisComp.layer(“engrane delgado/engranes SMALL.psd 2”).transform.zRotation

    I’m getting an AE error that states that an invalid numeric result (divide by zero?) is going on.

    If I place the first portion of the expression (“rot=”) everything goes ok, I get rot= on the comp, if I place the second portion of the expression (the code I got from the pickwhip it works fine too, it’s only when I put all of it that goes crazy.

    Can anyone tell me what I’m doing wrong?

    Thanks in advance.

    ("rot=") + thisComp.layer("engrane delgado/engranes SMALL.psd 2").transform.zRotation;

    David Cabestany replied 15 years, 1 month ago 2 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    March 26, 2011 at 4:55 pm

    This is one of those situations where, for some reason, you have to add .value to the object. Try it this way:

    (“rot=”) + thisComp.layer(“engrane delgado/engranes SMALL.psd 2”).transform.zRotation.value;

    Dan

  • David Cabestany

    March 26, 2011 at 5:04 pm

    Wow, that did it, thanks! Specially for replying so fast.

    Can you explain a bit further on what the .value command is adding to the expression? I that a new rule for CS5?

    Thanks again!

  • Dan Ebberts

    March 26, 2011 at 5:16 pm

    That particular expression wouldn’t have worked in CS4 without the modification. What’s going on is that your original expression is telling AE to add a zRotation property (which is an object) to the string “rot”. In most situations, the expression engine figures out that you really want to add the value of the object (a number) to the string and makes the conversion for you. But in some cases (and I really haven’t taken the time to figure which circumstances cause this behavior), you have to explicitly tell it to use the value, not the object. I know I’ve run into it before with Checkbox Controls in some situations. Just something to put in your bag of tricks.

    Dan

  • David Cabestany

    March 26, 2011 at 6:17 pm

    Thanks a lot!

  • David Cabestany

    March 26, 2011 at 6:49 pm

    Hey Dan, I found another method, thought it might be worth sharing:

    x=Math.round(thisComp.layer(“pieza 2/engranes SMALL”).transform.zRotation);
    “x=” +x

    This is an expression I’m using at a different layer, in which I’m using Math.round, but the structure is the same, I just created a variable, apparently it worked.

  • Dan Ebberts

    March 26, 2011 at 7:33 pm

    Using Math.round(), you shouldn’t even need the intermediate variable (x) because Math.round() generates a number.

    Dan

  • David Cabestany

    March 27, 2011 at 6:35 am

    I see, thanks for clearing that up.

    Best,

    David.

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