Grasshopper

algorithmic modeling for Rhino

Hi, I'm sure this is a dumb question, but I'm new to Python and I am trying to generate random numbers in the Python Component. I've already tried:

import random

random.range(x,z)

but it doesn't seem to work in the component.  It works in ironpython in Rhino itself but not the component.  Hopefully this is a quick fix and just me making a beginers mistake, so please let me know if you know the answer.  Thank you.

Views: 3240

Replies to This Discussion

I think there is nor random.range() command

You´re looking for random.uniform(a,b)

http://docs.python.org/2/library/random.html

This will work:

import random
a = random.uniform( x , y)

Thank you!!

I knew it was something stupid like that, in my defense I had looked stuff up and several sources told me random.range was thing, lol.

Thanks again!

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service