Little fix for my file

Hello !

I have difficulties to solve a problem and maybe someone will find me dumb for that. What the hell if you can give me a little help… :slight_smile:

I’m trying to randomly place some curves along a line, but they have differents dimension. If i use the orient direction, it resize some shapes to fit them.

I need to create modules of 6 times the minimal lengh, and i have curves that does 1, 2 or 3 times the minimal lengh.
A drawing will speak better than my english :

Here the GH file : Groues vagues (22.5 KB)

Thank you !

Côme Bocabeille

Groues vagues (24.8 KB)

Thank you a lot for your help, but this is not what i need.

I have a lengh (let say 150), and small modules of 3 lenghs (25, 50 and 75). I need to fill the full length with several small modules, sometimes even severals same ones.
The full length must be 150, so it can be 25+25+25+50+25, or 50+25+50+25 or again 75+25+25+25, etc.

Where i have the most issues is to make GH understand that i have a length that it can divide in only 3 types of length and affiliate those to curves.

I don’t know, maybe it’s not possible…?

And thank you a lot to help me ! :slight_smile:

Not directly I think. I suspect you’ll have to generate lots of random sequences, then measure the lengths and discard the wrong ones. If you’re unlucky it may well be that the vast majority of sequences don’t fit the bill.

A more efficient approach may be to manually create all valid ratios, and randomly shuffle their contents. But if there’s like a 1000 possible distributions that would take a long time too.

I did calculate, but the result is 2^27 possibillities. So about 134millions. :smiley:
I will simplify it and choose 5 to 10 corrects results and use them only for my project. Thanks for the help !

Hi @cbocabeille,

What result set do you want to achieve? One random solution? A small number of solutions? All solutions?


I wanted to have the choices of all possibilities, to make differents uniques panels for a facade of a building. i’ll not need 134 millions possibilities, but if each panel of the building is different, it will be like some hundreds. But i decided for now (just the drawing) to go with 8 solutions that i saved, and with some symetry/mirror of GH, i manage to have the illusion that nothing is really repeated.

Hi @cbocabeille,

Here is a GH python component that generates random combinations of lengths which fit into a target length. You can choose how many solutions to generate, whether they are random or adjusted not to repeat, how many different lengths to work with. You can optionally supply a seed value and thereby make the sequences repeatable, or leave it out to get random results.

Groues vagues (2.9 KB)

It only deals with the lengths - you would have to add components to do the drawing.

Hope you find it interesting,

1 Like

This is really impressive…
Thank you a lot for the help, it’s a elegant and efficient solution.
Have a nice day !