Rudinie Posted May 13, 2009 Share Posted May 13, 2009 (edited) I'm trying to create a bunch of random letters but i don't really know how to get it done. My plan was to use a `trunc(fit(rand($ID),0,1,a,z))` with a and z being the ansi codes of the range of characters i want to use. I do however not know how to turn a number into the corresponding character. Another option would be to use a substring from a predifined string with all the characters i want to include but i don't know how to get a substring out of a variable neither. Yet another way would be to make all characters as objects and just use a random number to select with object to merge but that's not a very ellegant way to do it i think. Can anyone put me in the right direction? Edited May 13, 2009 by Rudinie Quote Link to comment Share on other sites More sharing options...
Netvudu Posted May 13, 2009 Share Posted May 13, 2009 argh...I swear I can Quote Link to comment Share on other sites More sharing options...
anim Posted May 13, 2009 Share Posted May 13, 2009 to get character based on something like ASCII number you can type \\`33` in the text parameter of the font sop it will give you letter A which corresponds to code 33 (at least in houdini, i am not sure what table it is based on) so you can create code range for your stamp variable e.g : variable char = round(fit01(rand($ID),65,90)) codes 65-90 correspond to lowercase a-z and in your copied font sop put this in text field \\`stamp("../copy1","char",65)` there is also possibility to create character set and use random characters from this set the set will be string parameter in space separated characters like: a b c x y z 1 2 3 and then you can use expressions like arg() and argc() to choose random character from this set and use for stamping 1 Quote Link to comment Share on other sites More sharing options...
Netvudu Posted May 13, 2009 Share Posted May 13, 2009 (edited) Wait, I remembered. If you use the "\\" it will use ASCII code instead of what you write, so you have access to all characters. The 33 thing that anin wrote above is because the first 31 non-printing characters are skipped, so you actualy have 93 instead of 127 characters. If you write \\`int(fit01(rand($F),1,94))` at the Font SOP it will give you every possible character , or use 65-90 for lower case letters. EDIT: anim beat me to it. He Edited May 13, 2009 by Netvudu 1 Quote Link to comment Share on other sites More sharing options...
Rudinie Posted May 13, 2009 Author Share Posted May 13, 2009 If you use the "\\" it will use ASCII code instead of what you write, Cool, i actually have the Craig Zerouni book in front of me now, page 42, the font sop. Thank you both for the fast reply. Quote Link to comment Share on other sites More sharing options...
kumpa Posted May 13, 2009 Share Posted May 13, 2009 you can also type something like this: `arg("A B C D E",stamp("../copy1",letter,1))` 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.