MVB Posted March 31, 2011 Share Posted March 31, 2011 Hello, Here's an example of the Python code which is being stamped. import random x = ['2', 4, 8, 1, 'fubar', '2&1', 1.1] return random.choice(x) However once it is stamped into the text parameter of a Font SOP it only outputs the float/integer items and not the strings in the list. Is it something to do with the Copy SOP's 'val1' parameter being a float? Basically I need to randomly select items from an externally created list of varying length and stamp those items onto points particles etc... Can anybody please point out the obvious for me? Cheers! I've attached my .hip example_mvb.hip Quote Link to comment Share on other sites More sharing options...
graham Posted March 31, 2011 Share Posted March 31, 2011 As you mentioned, your main problem is that you are trying to return strings and numbers in a float parameter. The proper solution would be to just have the stamp variable value as $PT from the input points and then stamp from the Text parm on your Font SOP. This method doesn't care if you are returning strings or numbers. Another issue is that you are just using a pure random generator without any sort of seeding. This results in purely random results every time you cook so there's no continuity. In the attached file I use the $PT stamp var to drive ramdon.seed() so I get randomness but maintain the randomness every cook. Alternatively you could instead use the standard Houdini randomization, hou.hmath.rand() using the stamp value and then multiply and convert to int accordingly to get the correct range of values. example_mvb.hip Quote Link to comment Share on other sites More sharing options...
MVB Posted April 1, 2011 Author Share Posted April 1, 2011 Thanks graham that's exactly what I wanted. I've always been one to try and run before I can walk, most appreciated. Quote Link to comment Share on other sites More sharing options...
Matt_K Posted April 1, 2011 Share Posted April 1, 2011 Thanks guys! I'm currently getting into python and it's problems/files like this that are a great help! Matt. 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.