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
Font tool and generated numbers....
7033 10 3- lawrencen
- Member
- 16 posts
- Joined: 6月 2015
- Offline
- goldfarb
- スタッフ
- 3463 posts
- Joined: 7月 2005
- Offline
- lawrencen
- Member
- 16 posts
- Joined: 6月 2015
- Offline
- lawrencen
- Member
- 16 posts
- Joined: 6月 2015
- Offline
- goldfarb
- スタッフ
- 3463 posts
- Joined: 7月 2005
- Offline
- lawrencen
- Member
- 16 posts
- Joined: 6月 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
L
- lawrencen
- Member
- 16 posts
- Joined: 6月 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
L
- lfranceschini
- Member
- 72 posts
- Joined: 4月 2016
- Offline
I think you are looking for sprintf [www.sidefx.com]. You can use 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.
sprintf("%.2f", f)
Edited by lfranceschini - 2017年11月10日 17:26:53
- galagast
- Member
- 252 posts
- Joined:
- Offline
- lawrencen
- Member
- 16 posts
- Joined: 6月 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!
- galagast
- Member
- 252 posts
- Joined:
- Offline
-
- Quick Links