Regenerating Random Numbers

by Tuğrul Yazar | January 2, 2013 11:09

2013_01_02-randomtim

Just a quick tip as I thought might be useful in some cases. Generating random numbers in architectural scripting is not a too catchy thing for designers. It is for sure, we want every parameter to be under our control (as if it were possible!). I was thinking about that in Grasshopper. A dataflow graph such as in Grasshopper regenerates whenever necessary (a change on an input value “fires” every connected component), therefore random number component requires your action (for example changing a seed value using a slider) in order to regenerate again. I tried to connect a timer component to random but could not tell it to regenerate numbers in a timed interval. So, I wrote a vb.net component including a very simple code in it. It just generates a random integer between 0-100 as displayed above. Below is the code within the VB component, you can change “100” to your desired range there. Now, if you connect a timer component, you’ll see that it works now.

2013_01_02-randomtim

Here is the same functionality with the new Python Script component:

2013_01_02-randomtim2
2013_01_02-randomtim2

Here is the Grasshopper definition if you want to try both scripting environments (note that the Python script component is a part of Grasshopper for Rhino 5): [GHX: 0.9.0014][1]

Endnotes:
  1. [GHX: 0.9.0014]: https://www.designcoding.net/decoder/wp-content/uploads/2013/01/2013_01_02-randoms.ghx

Source URL: https://www.designcoding.net/regenerating-random-numbers/