Jump to content

make the float value always 4 digits


Juzwa

Recommended Posts

Hi, 

 

I have some animated parameter from some channel and I use it on the font SOP to display it's value in the viewport.

 

How do I make this value to be always a 3 or 4 digit? eg: 

 

- when the value is 0 i want to display 000

- when the value is 5.6663562 5.66

- when the value is 100 i want 100

Link to comment
Share on other sites

E.g. with hexpression (but this example works only for positive numbers):

{
in = fit01(fit($F,1,100,0,1),0.0,150.0);    # input data
digits = 4;                                 # digits to display
d = digits-strlen(int(in));
mult = 10^d;
out = int(in*mult)/mult;                    # adjust tenths values
return ifs(out==0,padzero(digits,out),out); # fix for 0
}

pz_round_to_digits.hip

  • Like 2
Link to comment
Share on other sites

Hi, 

 

Sorry for such late response. 

 

Thank you so much. But I'm having some problems. Your example works fine. But when I copy/paste the code to the font SOP I get the code itself, it does not evaluate, how do I make it to evaluate in the font?

 

EDIT: Ok found it > edit expression, then paste and hit apply. Thank you so much!

Edited by Juzwa
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...