EdwardBrian Posted December 18, 2010 Share Posted December 18, 2010 Hi, one of those questions where the answer is propably easier than binding your shoes but you didn´t have a coffee for several hours and therefor your brain is frozen (thats me...) My Problem: Im am using a font sop to display the distance an object is traveling in the scene (simulating a digital display). I just don´t get it right so that it is 1.) only displaying 2 decimal points like 25.76 and 2.) displays 34.00 and not 34 as it is automatically doing. Any help will be highly appreciated. Quote Link to comment Share on other sites More sharing options...
Macha Posted December 18, 2010 Share Posted December 18, 2010 for 1) you can use trunc like so: trunc(100*$ATTRIBUTE)/100 but you are right, when there is an end-zero it will not display it, so I don't know the answer to 2) unless you want to use Python, in which case it is probably is quite easy. Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted December 19, 2010 Share Posted December 19, 2010 As an hscript expression in the 'Text' field of a FontSOP? Maybe you can try: `padzero(2,trunc($NUM))`.`padzero(2,trunc(round(frac($NUM)*100)))` Where you'd replace '$NUM' with whatever the number is that you need to represent, and change the two constants ('2') with the amount of zero-padding you want on either side of the decimal point (which the power-of-ten on the right side should also match, of course). Cheers. 2 Quote Link to comment Share on other sites More sharing options...
pclaes Posted December 20, 2010 Share Posted December 20, 2010 Neat! I was still thinking in numbers, should be thinking in characters instead, nice! Quote Link to comment Share on other sites More sharing options...
Fake Pilot Posted February 23, 2018 Share Posted February 23, 2018 I've been trying this function, but with the attempt of only showing 1 decimal. However I do it, it seems to sometimes show .10 instead of .0. How do I get around that? Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 24, 2018 Share Posted February 24, 2018 Using Python: 'Time: %.1f' % hou.time() Using VEX sprintf(): // Detail wrangle. s@num = sprintf("%.1f", @Time); in Font node: Time: `details("../attribwrangle1", "num")` format_font.hipnc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.