String to float for random

   6257   2   1
User Avatar
Member
280 posts
Joined: Dec. 2015
Offline
How would I transform a string attribute into a float to use in random.

I am trying to use the name attribute produce by the assemble SOP which is string to randomly give color to each primitive.

but rand (@name) will not work… I assume because it requires a float.

Any ideas?
https://www.imdb.com/name/nm8408875/ [www.imdb.com]
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
could be worth checking out the atoi vex function

http://www.sidefx.com/docs/houdini15.0/vex/functions/atoi [sidefx.com]
Edited by megasets - Sept. 13, 2016 14:03:28
Sam Swift-Glasman
Art Director
Five AI
User Avatar
Member
280 posts
Joined: Dec. 2015
Offline
thank you very much @glassman3d….
I solve it with atoi here:
int num_name = atoi (strip (@name,“name”));
@Cd = set (rand (num_name),rand (num_name),rand (num_name));
https://www.imdb.com/name/nm8408875/ [www.imdb.com]
  • Quick Links