algorithmic modeling for Rhino

Hi All,

I've got a few curves with lengths x,y,z etc that are all multiples of 12. I want to get random combinations of a select group of numbers (24,36,48 and 60) to add up to each of the lengths (One random combination per length, including the possibility of repeats - two 24's, one 36 and one 60 for example)
And then divide each curve into points based on the associated combination.
So far I've been thinking that the solution is in using 12 as a divisor, the lengths as the dividend, using the quotient as the stack of 12's to combine into random combinations of 24, 36, 48 and 60.
I've got the quotient stacks of 12 associated with each curve length but am having trouble combining the 12's into random combinations of 24,36,48 and 60 including repetitions.
Any help would be greatly appreciated. Also I'm sure there are much better ways of doing this than starting with a stack of 12's and I'd welcome any input about those as well.
Thank you,

Views: 810

Replies to This Discussion

I don't quite understand what you're trying to do...?

But noticed that "24, 36, 48 and 60" are multiples of 2, 3, 4 and 5 - so I generated a sequence of 100 random values like this:

Note that the 'Random' component has been configured (right click) to generate integers.


Hi Joseph,

Thank you for your response.

Attached are two images and my script that better explain what I am trying to do.

The end goal is to divide each of the 3 curves with lengths 60, 108 and 168 (shown in the image) into lengths that are some combination of the numbers 24,36,48 and 60. 

I have also generated a randomized list of the number set 24,36,48 and 60 from which to select these combinations. The issues I'm currently having are:

1. The number of random values that the random component is currently selecting from the list is based on each curve length divided by 24. My logic was that dividing each curve length with the smallest number in the set of 24,36, 48 and 60 would give the minimum amount of numbers I have to select randomly. However because the set also has 36,48 and 60, The script very quickly overshoots the curve length. So I am not sure what logic to use to set how many random numbers from the list I should pick for each curve.

2. I need to make this recursive because, currently the seed value for the random selection will remain the same and so I will get the same combination for every length. 

The 3 curves shown are just an example. I have 100's of curves that I need to do this to.

My script is attached as well. Hope this helps clarify my query.




Posting your code will drastically improve your chances of getting help!

I'm not sure I'll be spending any time digging into this but without looking at your code (yet), I'll say this much:

  1. I don't think you need recursion to modify the random seed; many other ways to accomplish that (use the length of each curve as the seed, for example).
  2. Using multiples of twelve makes it harder for me to grasp the essence of the matter; another way of looking at it is that you want to generate random integers from 2 to 5 (24,36, 48 and 60) and have them add up exactly to curve lengths of 5 (x12=60), 9 (x12=108) or 14 (x12=168).

So you want to generate random numbers until their sum ('Mass Addition') plus 5 is equal to or greater than the curve length (5, 9 or 14).  The last number in the series is then not random but just the difference between the two.

For example, for curve length = 5 (x12=60), there are only three possible numbers that can be used as the first in the sequence: 2, 3 or 5.  If it's 5, you're done.  If it's 2, the second number is 3 (5-2), if it's 3, the second number is 2 (5 - 3).  You can't use '4' at all because the remainder, 1 (x12=12) isn't one of your solution options.

There is no point in generating the last number randomly, eh?

P.S.  You didn't use 'Internalize data' for the 'Curve (Crv)' param in your GH file.






  • Add Photos
  • View All


  • Add Videos
  • View All

© 2023   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service