# Scripting in GH Part 07

Software:
Tag:
Video Duration:
12 minutes
Author:
Zach Downey

Nested loops!  In this tutorial we create a grid of points by nesting two for-loops inside one another.  This one is a little bit more complex in the way it operates.  Basically the way the two for-loops work is that we enter into the first loop and assign an x-value to a point.  After it sets the x-value of the point we enter into the second loop and set the y-value of that point and then add the point to the list.  Then we stay in that second loop and the x-value remains the same, but we increment the y-value by the step increment and add it to the list.  This continues until we meet the condition in the second loop at which point we jump out of that loop and go back to the first loop.  We then increment the x-value and continue the whole process again until we meet the condition of the first loop.  Then both loops are exited and we return our list of points.

```List<Point3d> pts = new List<Point3d>();

if (x == null) {
x = new Point3d(0,0,0);
}

double spacingX = xSize / numDivsX;
double spacingY = ySize / numDivsY;

Point3d tempPt = x;

for (int i = 0; i < numDivsX; i++) {
tempPt.X = x.X + (spacingX * i);

for (int j = 0; j < numDivsY; j++) {
tempPt.Y = x.Y + (spacingY * j);
}
}

A = pts;```

### Rating

Please rate this tutorial below. Thanks.