Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions flipping property values from negative to positive. . .

  • flipping property values from negative to positive. . .

    Posted by Darren Gardner on October 16, 2008 at 5:50 pm
    thisComp.layer("AE solid").position[0]-thisComp.width/2;

    Can an expression be written that changes negative transform property values to positive? What I mean is, say the position X transform property is 360. I want to write expression that will automatically convert the value to -360, and vise versa.

    The reason I need this is because I’m trying to link the coordinates of a layer set in 3D Invigorator classic to the 3D position and rotation values of an AE solid. I used this expression to do it -‘thisComp.layer(“AE solid”).position[0]-thisComp.width/2;’. It worked, but it appears that the coordinate system for 3D Invigorator is opposite the coordinate system in AE. When the AE solid goes left, the Invigorator object goes right. See what I mean?

    Any help would be great!

    Thanks Again Creative Cow! You are ever faithful!

    Darren

    Armand Rusinov replied 11 years, 11 months ago 4 Members · 5 Replies
  • 5 Replies
  • Darren Gardner

    October 16, 2008 at 6:06 pm
    y=thisComp.layer("AE solid").position[1]-thisComp.height/2;
    y/-1
    

    I found the answer to my own question on an earlier post! I guess I just wasn’t putting in the right key words for the search the first time I tried.

    check out – https://forums.creativecow.net/thread/227/9772#9773

    The answer was pretty simple. Just divide the value by -1 (positive 1 depending on which way you want to go).

    Hope this helps anyone else in the same predicament.

    Thanks!

    Darren

  • Darby Edelen

    October 16, 2008 at 7:24 pm

    [Darren Gardner] “The answer was pretty simple. Just divide the value by -1 (positive 1 depending on which way you want to go).”

    Dividing by 1 would return the same result… Dividing by -1 will change the sign of the value as you wanted, but there’s a much easier way to do it:

    value //the original value
    -value //the value with with its sign changed

    Just add a negative sign in front of the value. So in your example, instead of:

    y = thisComp.layer("AE solid").position[1]-thisComp.height/2;

    You could use:

    y = -(thisComp.layer("AE solid").position[1]-thisComp.height/2);

    Darby Edelen

  • Darren Gardner

    October 16, 2008 at 10:14 pm

    Hey Thanks! More than one way to achieve it! That is easier! I appreciate it!
    Oh, and you’re right. Divide by 1 will return 1. I spoke too soon on that one.

    Thanks for your help!

    Darren

  • Leon Ouwendijk

    March 22, 2012 at 10:31 am

    Thanks Darren Gardner and Darby Edelen!
    I’m animating a pair of irregularly flapping wings and couldn’t for the life of me figure out how to pair the rotation of one wing to the reverse value of the other!

    Microsoft is notorious for not giving us what we want. Apple is famous for making us believe what we want.
    Adobe is the unsung hero for giving us what we need.

  • Armand Rusinov

    June 7, 2014 at 11:32 pm

    Well, that *almost* worked for me LOL. I was looking for this exact thing. It does as advertised, but I was looking to do some dynamic fog in Element 3D. I used a world position pass to create the heavy fog and wanted to give it some texture with fractal noise. Everything looked awesome up until the moment I moved the camera. So I tethered the turbulence offset to the camera and it moved with it, but again, it didn’t move in the right direction. So I did what you said and it moved in the right direction but now it still looked weird as hell. I am guessing I’d have to do it into a layered pre-comp and then offset the value of each layer with some kind of *0.001, *0.005, *0.01, etc. Too much work for an experiment.

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