# Grid Spacing

Hi All,

Just hoping that someone better than me at maths can lend a hand…

I have a grid generator which is happy making grids at a regular spacing using a sequence node…

But as we know a grid will tend to have a module, say it repeats every 5, which is different.

So my grid spacing is 7m, 14m, 21m, 28m, 31.5m 38.5m etc.

Or to put another way n, 2n, 3n, 4n, 4n+x, 5n+x … 10n+2x etc.

I would be grateful if anyone could help me interpret that into Dynamo…

Thanks!

Mark

hello mark,
if you start something in dynamo and put it here so it will be better to understand

@Mark.Ackerley Maybe something like shown below

Grid Spacing.dyn (16.9 KB)

2 Likes

That is awesome, thanks so much!

Having the sequence explicit like that is a great idea… And list scan is a new node for me!

FYI, this is the grid generator as implemented…

Thanks again,

Mark

GridGenerator-OffGrids.dyn (115.3 KB)

1 Like

See if this helps …
gridSpacing.dyn (5.8 KB)

``````a = (spng*(itrv-1)+incr)*(0..Math.Ceiling(grct/itrv));
b = List.TakeItems(List.Flatten(a..#itrv..spng,-1),grct);``````
3 Likes

Hi Vikram.

That is fantastic, thank you.

I’ve rebuilt your code with nodes so I can work out what the heck is going on! Just a couple of questions if that’s ok…

Could you explain what the # is doing in the line I get that we’re making a range, starting with a, stepping with itrv? and ending at spng?

If I write your code into a code-block i get a List input, do you know how I can stop that?

Thanks again,

Mark

The #itrv in this case fixes the number of steps, with a stepsize of spng, so no fixed end value.

a: the number at which to start
#itrv: the number of items in the range (itrv being the number)
spng: the step/incement

A simple example …

This is due to a conflict with some package/s you have installed
Prefix List with DSCore.

`b = DSCore.List.TakeItems(DSCore.List.Flatten(a..#itrv..spng,-1),grct);`

Node version …

gridSpacing-nodes.dyn (24.2 KB)

1 Like

Thanks guys,

I’m learning some great Design Script knowledge today and that’s a nice demonstration of the difference between a Sequence and a Range!

For anyone as dim as me, here’s my annotated version…

Grid Spacing.dyn (12.8 KB)

3 Likes

It doesn’t necessarily have to be that complex. If the ratios remain the same and the only thing that changes is the module and the constant, the design script syntax for the above would be almost identical to what you wrote:

just replace the curly braces with square ones in Dynamo 2.0

5 Likes