Font tool and generated numbers....

   7146   10   3
User Avatar
Member
16 posts
Joined: June 2015
Offline
Hi guys. Im new to Houdini and don't really script. Coming from Softimage I am able to do most things I want in Vops & Sops so am enjoying my stay in Houdiniville so far.

I am trying to generate Type (Numbers) that are random to two decimal places. Now, the Font tool and using the Copy Stamp and using the variables. Got that far so I can put a different number on each point of my grid. Currently I have an attribute that I am creating a random number for in a Point Vop (could be quicker with wrangle Im sure). And that random number is the number copy stamp of the font is making. Awesome.

My problem is I can either seam to get my VOP to make a number that is an integer (by rint) or a number that has lots and lots of decimal places. there is no way to round it to two decimal places easily. I tried using nodes to multiply the number to make it big, then truncating it as an integer then dividing by 100 etc to introduce decimal places. but that doesn't work either.

How can I make a random number between a range but have it stick to two decimal places, and yes have a zero if its a clean 10th so it might be 14.30 for instance.

Any help would be awesome. This is automatic option in the type tool in Maya but I really want to keep this in Houdini if I can.

Lawrence
User Avatar
Staff
3464 posts
Joined: July 2005
Offline
you can try using padzero:
http://www.sidefx.com/docs/houdini/expressions/padzero [www.sidefx.com]
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
16 posts
Joined: June 2015
Offline
And how do I apply that to a float attribute that has been generated already before it gets passed onto the copy stamp?
User Avatar
Member
16 posts
Joined: June 2015
Offline
That also seems to pad zeros to the left of the number and truncates the decimals, or am I using it wrong? I need to keep 2 decimal places.

thanks for your help.
User Avatar
Staff
3464 posts
Joined: July 2005
Offline
ops, yeah, you'll have to use python
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
16 posts
Joined: June 2015
Offline
Ok. I have used all the expression tricks and seems it is impossible to do what I want and I need to use Python as you say - which I don't know so won't do. I find this to be kinda crazy. Needs to be a away in Vex and in VOP to round to x decimal places (and paid before like pad zero). I am stunned this is so hard. I need to do numbers like in a stock app so they need to be clean and to two decimal places. for some mograph work and Im off to another DCC

L
User Avatar
Member
16 posts
Joined: June 2015
Offline
Ok. I have used all the expression tricks and seems it is impossible to do what I want and I need to use Python as you say - which I don't know so won't do. I find this to be kinda crazy. Needs to be a away in Vex and in VOP to round to x decimal places (and paid before like pad zero). I am stunned this is so hard. I need to do numbers like in a stock app so they need to be clean and to two decimal places. for some mograph work and Im off to another DCC

L
User Avatar
Member
72 posts
Joined: April 2016
Offline
I think you are looking for sprintf [www.sidefx.com]. You can use
sprintf("%.2f", f)
to get a string representation of the floating point number f rounded to two decimal places, padding the right with zeroes if necessary. There is more information on the formatting available in the printf [www.sidefx.com] documentation.
Edited by lfranceschini - Nov. 10, 2017 17:26:53
User Avatar
Member
252 posts
Joined:
Offline
Hi, here's a vex approach (assuming I understood what you were after).



H16.5.268 Indie - font_rand.rar
Edited by galagast - Nov. 10, 2017 17:41:17

Attachments:
font_rand.JPG (23.8 KB)
font_rand.rar (11.4 KB)

User Avatar
Member
16 posts
Joined: June 2015
Offline
galagast
Hi, here's a vex approach (assuming I understood what you were after).

Attachment Not Found


H16.5.268 Indie - font_rand.rar

If you are in New York I will buy you a beer, just say when.

This is awesome and very helpful

**that being said, come on sidefx - lets add some versatility to the Round to Integer (make it rough and be to integer or decimal) and have the ability to truncate as well easily***

Thanks so much galagast!
User Avatar
Member
252 posts
Joined:
Offline
Haha, Glad to be of help! Cheers!
  • Quick Links