Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Simple expression problem

  • Simple expression problem

    Posted by Conan Stott on September 23, 2009 at 2:29 am

    HI, I am very new to expressions, and have a simple question. One so simple I suspect its the reason I can not find the question asked while doing a search.

    I have created a spinning arrow in a clockwise direction and have used the expression: time*30

    On the opacity operator I have used an expression to make the arrow change opacity at certain degrees.

    if ( rotation<180 || rotation>240) 100 else 50

    This works fine for one full 360 degree circle but the opacity stops changing once it gets past one complete circle. for instance 1×360 e.t.c

    Any Idea what I need to add to the expression in order for it to continue changing the opacity values? Or does the rotation require a different method of making it turn?

    Thank you, appreciate your help.

    Regards

    Conan

    Conan Stott replied 16 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Curious Turtle

    September 23, 2009 at 7:48 am

    This will get just the degrees for you, and not the number of complete rotations:

    a=thisComp.layer("YOUR LAYER").transform.rotation;
    if (a>=360) a=a%360;
    a

    So you just need to slot this into your existing expression.

    All the best,
    Ben

    Curious Turtle Pro Video
    Training | Editing | Support
    Out Now – Film Wash Color Effects Vol. 3
    for After Effects & Apple Color

  • Conan Stott

    September 24, 2009 at 1:07 am

    Hi, thank you very much for this, but I still am having trouble with it.

    I am learning so have probably miss interpreted the expression but heres how I make it out. Please tell me where I am going wrong.

    You have defined a as the value of the layers rotation property with the line

    a=thisComp.layer(“YOUR LAYER”).transform.rotation; in my case the layer name is Arrow so I have he line as

    a=thisComp.layer(“Arrow”).transform.rotation;

    then with the line: if (a>=360) a=a%360;
    You have made a statement saying that if “a” is greater than or equal to 360 the value of “a” will be a % 360.

    This makes sense to me as it is making the rotation value remain within the 0 to 360 degree value without the 1x e.t.c

    My problem arrises in getting my line in the expression so the arrow will behave how I want it to.

    if (rotation<180 || rotation>240) 100 else 50

    Currently, if I put this last I get the same problem that the effect only works on one complete cycle.
    If I put it first I get an interesting effect (the same thing will occur if I leave out this line altogether) where the arrow starts its cycle at 0% opacity and will slowly fade to 100% opacity at exactly 100 degree rotation.

    I can kind of see why this would be, but am unable to find a solution with my current level of skill in expressions. I have tried various things but none seem to work. Would really appreciate the help in this 🙂

    PS.. I am applying this to the opacity operator. If I am supposed to apply it to the Rotation operator I also get the problem that my time*60 is ignored or it supercedes the previous expression if applied last.

  • Curious Turtle

    September 24, 2009 at 4:42 am

    You’re right to apply it to Opacity. Sorry, I should probably have been clearer and not assumed so much. Your reading of the expression was bang on, but you didn’t apply the data you got to the final result.

    Here’s the final expression:

    a=thisComp.layer("Arrow").transform.rotation;
    if (a>=360) a=a%360;
    if (a<180 || a>240) 100 else 50

    So what we’re doing is feeding in the data we get from rotation%360 into your final if/else.

    Does that make sense? And more importantly, does that work how you want it to?

    Cheers,
    Ben

    Curious Turtle Pro Video
    Training | Editing | Support
    Out Now – Film Wash Color Effects Vol. 3
    for After Effects & Apple Color

  • Conan Stott

    September 25, 2009 at 5:00 am

    Ahh yes, thank you. I came very close to that myself at some point but probably just missed something out. Awesome, thanks I appreciate the help and learning expressions is made much easier when working through a problem such as this and getting help with it.

    Thank you

    have a good day

    Conan

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