Inserting a list between a fixed index interval

Hi guys!!

I am trying to create a list of 0s and after a fixed amount of lets say 23. after the 23rd “0” it will increase to 800 and so on…

Is there a code that can do this?

What i am trying to accomplish is to insert detail groups in a snake like pattern with a 500 distance between each other.

the values would probably be like this
(i will just have 7 items per row with 4 rows for an example)

x = 0,500,1000,1500,2000,2500,3000,
y = 0,0,0,0,0,0,0,
z = 0

I am having a hard time understanding what you want to accomplish. Can you show your attempt in Dynamo or explain with pictures/plan?

If you just want to do this part:

something like this would work:

1 Like

Hi Kenny,

Thanks for your reply! :slight_smile:
This is what i would like to accomplish. The location of every icon(item) in the diagram below.

I have attached what i have done so far. So i was able to only make out a straight line. although i can manually type the coordinates one by one and.make the list myself but it is time consuming.
Fire Alarm Schematic Diagram.dyn (110.5 KB)

So far what i can only do is these items on a straight line. not on a “S-like” pattern.

That solved part of my problem hahaha at least i got the Y coordinates sorted out.
I Hope you there is a solution for my X coordinates.

CHeers!! :smile:

Can you draw a line on that picture for how you want the items to snake around?

Hi Kenny.
Picture below.

Thanks in advance.:smile:


So I gave up trying to do this in node form because it is much easier to do with python:

# Enable Python support and load DesignScript library
import clr
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
xDist = IN[0]
xInRow = IN[1]
yDist = IN[2]
yInRow = IN[3]
zValue = IN[4]

xList = range(0,xDist * xInRow,xDist)
yList = range(0,yDist * yInRow,yDist)

listX = []
listY = []
# X list
for i in range(yInRow):
	if i % 2 == 0:
#Flatten the X list:
flatX = [item for sublist in listX for item in sublist]

# Y list
for j in range(yInRow*xInRow):

pointList = []
for x,y in zip(flatX,listY):
OUT = pointList

It outputs a list of points that snake around like you asked. It can be modified to output just the X and Y values if you want it to be. Maybe someone like @mellouze can do it better in node form.

1 Like

Hi Kenny,

Amazing!! I was still trying to solve this using some kind of loop node but this is way better!
Thank you so much!!
Cheers :laughing:

1 Like

Hi @kennyb6 :slight_smile:

Here it is. I’m not 100% convinced of the Imperative block, I believe we can do better, but I honestly have still some issues with the If statements in CodeBlock (you know, the a?b:c; syntax).

xList = 0..xDist*(xInRow-1)..xDist;
yList = 0..yDist*(yInRow-1)..yDist;
points = Point.ByCoordinates(xList<2>, yList<1>, zValue);
rev_points = List.Reverse(points@L2<1>);
boole = (0..yInRow-1)%2 == 1;
c = [Imperative]{
    for(i in 0..List.Count(boole)-1){
            result[i] = rev_points[i];
            result[i] = points[i];
    return = result;

1 Like

I always feel like using imperative code blocks are worse than using python because the syntax is so weird and it doesnt produce warnings half the time, just red errors. Any chance this could be done with only nodes?

1 Like

Feel that way too. I’ll give it a try without Imperative blocks.

1 Like

Hi again,

The solution without any Imperative block :slight_smile: (there is an If node though …)

xList = 0..xDist*(xInRow-1)..xDist;
yList = 0..yDist*(yInRow-1)..yDist;
points = Point.ByCoordinates(xList<2>, yList<1>, zValue);
boole = (0..yInRow-1)%2 == 1;
rev_points = List.Reverse(points@L2<1>);


Thank you @kennyb6 and @mellouze Everything is working now!