Points on a line, with min and max distance

I think this is one of those little things that at first looks really easy but then turns out not to be. I really wanted to do this with just the default nodes, but I think that it isn’t possible. You will either need to use custom recursive nodes, python or DesignScript.

The first task would be to define our line and our min and max distances. Then we’ll need to get the line’s length and normalize our min and max to that length. (in my example, my line is 5 meters, my min distance is 7cm and my max distance is 1m)

Capture1

Then the next step is to generate our random values that are in the range defined by our normalized min and max parameters and make sure that their total sum is less or equal to 1.

Capture2

And this is where we hit a snag. The LoopWhile node works great and makes sure that the sum of our parameters is less than 1. However at the moment the way that Dynamo works is that when you place a random generating node on the canvas, it only works once and then goes into lazy mode and spits out the same number over and over again. This is good in some cases but not good in others. I strongly believe that the random nodes should have a toggle which specifies if you want the number to be generated once per placement or each time you run your graph.

So for the time being we have to resort to recursion, python or DS as stated earlier.

I went with the DS approach:

Capture3

However keep in mind that this approach will re-generate your points every time you run the graph, so if you really like a set of points, you’ll need to store them to a csv/excel or other medium, or they will be lost forever :slight_smile:

Capture4

1 Like