-
Parsing numeric result as a string
Hey all,
This is probably a very easy fix– I’m working on creating a video overlay to make some footage look like it’s being viewed through a high-tech rangefinder with a compass. To add some extra pizazz I want to send the Rotation value of my compass layer to a text layer nearby, and after the actual number I wanted to add a degree symbol (°). So, the end result of my text layer would look something like this:
-1.274°
So I have two questions about getting this piece working. Firstly, the numeric result of just pickwhipping the compass’ Rotation value has WAY too many significant digits (14 decimal places!) and I’d like to come up with a way to have it round to the nearest thousandth of a degree. That’s probably just a Javascript thing that I’m not aware of just yet.
Secondly, I can’t seem to get the degree symbol tacked onto the end of my text layer’s value. I’ve posted the code I’m using below. I’ve tried other examples of mixing numbers and text in expressions without issue, but something seems to be wrong with what I’ve done here. When I use the code below, AE returns this error:
After Effects warning: invalid numeric result (divide by zero?)
Expression disabled.Error occurred at line 3.
Comp: ‘HUDforForm’
Layer: 2 (‘Bearing’)
Property: ‘Source Text’Is there a tried-and-true way to force AE to parse a numeric value as a string?
Thanks so much in advance!
Jared Flynn
Motion Graphics Designer / Lead AE
Lone Wolf Documentary GroupbearingVal = comp("Compass").layer("Modern_nautical_compass_rose_2000px.png").transform.rotation;bearingString = bearingVal + "°";
bearingString;
Jared Flynn
Motion Graphics Designer / Lead AE
Lone Wolf Documentary Group