Points on a line, with min and max distance

I want to create points on a line spaced at a random distance. The minimum distance between the points should be 3 inches (or x), and the maximum should 4 feet (or y).

Would someone please help me figure this out?



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)


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.


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:


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:


1 Like

I run into the same problem when generating random numbers, as far as I remember what I did was make custom node that takes 1 input(does nothing with it) and returns a random number, this way we can call the custom node over and over. so you’d have 3 inputs, the range, and a third input that does nothing so you can force it to re execute (I think this would work here)


As always, thank you very much for taking the time. I reached similar conclusion as you did, about the limits of standard nodes, and decided to DS the process.

I used similar logic, but slightly different method than you. What I had not mentioned in my initial post was just spacing the points was not going to be sufficient. I am trying to crated a facade configuration as show in the graphics below:



For this to work, the spacing between the panels had to be min and max. So simply placing panels on parametricized distance was not going to be sufficient - the panel size and to be accounted for.

Following its the DS node that I created it with:


Nice one, Aseem. Two thumbs up! :slight_smile:

hi, i’m trying to do the same thing on a curtain wall, i want randomized vertical mullions which the gap between them are min 450 max 1250, i went half way but it doesn’t work, i’d appreciate any help. 1.dyn (9.5 KB)

Please start a new thread with this instead of bumping this one. It’s two years old and things are quite different now.