Sometimes you want to reference the value of a parameter and display it as a string to put in a Font SOP, or the Viewport Comment of a Camera node when you’re wedging sims or making some sort of visualizer.
But quite often, if you’re referencing a
float parameter, you wind up getting allllll the digits that come with it, full precision and all, rather than just the nice value you see in the interface.
which is probably not what you want!
A possible solution to trim off some of the extra digits might look something like
Unfortunately, this fails too :(
The solution is actually quite simple! We can use the
ftrim() function from HScript.
ftrim() will strip off all those unwanted digits and leave you with a nice clean value, pretty much as you typed it!
Of course, this also works in a Font SOP too.
Update 9 Jan 2022
Here’s a handy snippet for programmatically wrapping channel references in
ftrim(). Taken from the Linewriter tool.