# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions connect rotation value to number generator

• # connect rotation value to number generator

Posted by on June 3, 2020 at 2:37 pm

Hello,

I’m an experienced AE user, but relatively in the dark when it comes to expressions. I don’t code at all, and have only ever used the pickwhip for basic stuff. I need to connect the rotation of a dial to a number generator and have it be accurate. I can do it with the pickwhip, but I don’t get the right values.

I’ve attached a basic picture of the comp. When the arrow is at 0 rotation, I need the numbers to be 50 and 50. When it is at -90 rotation, I need them at 100 and 0 etc…

Can someone help out? I don’t have time to spend all day muddling it out myself, even though that’s the best way to learn.

replied 4 years ago 3 Members · 5 Replies
• 5 Replies
• ### Andrei Popa

June 3, 2020 at 2:51 pm

I think you need to link a number to another and the line to only one of the numbers. Let’s say you link it to the one on the left. This should work. The “leftNumber” is the number of the layer on the left.
This expression goes to the rotation of your needle

numberVal = thisComp.layer(“leftNumber”).text.sourceText.value;
linear(numberVal,0,100,-90,90)

The right number should have this to it’s text, so it automatically updates to the one on the left:

numberVal = parseInt(thisComp.layer(“leftNumber”).text.sourceText.value);
100-numberVal;

Andrei
My Envato portfolio.

• ### Eric Suquet

June 3, 2020 at 3:28 pm

Thank you for responding so quickly.

I am having trouble implementing this though.

For reference I have named the left number LEFT and the right RIGHT. I applied this to the the arrow rotation:

and the results are similar to when I just pickwhip it. How do i get the number offset to be correct? this should be more like +65%

And then I can’t get the right number to connect at all to the left. I get this error:

• ### Robert Müller

June 3, 2020 at 3:32 pm

Hm wouldnt this affect the rotation of the needle based on the text value and not the other way around, since the expression is on the rotation of the needle?

I think it would be easier with these expressions.
For the left text:
```Math.round(linear(thisComp.layer("needle").transform.rotation,-90,90,100,0)) ```
And for the right text I just switched the mapped values:
`Math.round(linear(thisComp.layer("needle").transform.rotation,-90,90,0,100))`
I added the “Math.round” so that you’ll get clean values

• ### Eric Suquet

June 3, 2020 at 3:34 pm

sorry, the second image should be this:

• ### Eric Suquet

June 3, 2020 at 3:37 pm

That worked wonderfully. THANKS!

We use anonymous cookies to give you the best experience we can.