RevitPythonShell: Create Points

## Introduction

Points are the easiest type of geometry to define (of course!). There are two variable types to be aware of when creating a point…

1. XYZ Variable: A variable for storing x, y, z coordinates and defining vectors.
2. Reference Point Variable: Uses XYZ to create a visible reference point in space.

#### Single Point

The following code uses variables x, y, and z to define an XYZ variable. A reference point is then created using doc.FamilyCreate.NewReferencePoint()

The code creates a single point in the Mass family at the coordinate 10,10,0

```import clr
from Autodesk.Revit.DB import *

app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document

t = Transaction(doc, 'create a single reference point')

t.Start()

#define x, y, and z variables
x = 10
y = 10
z = 0

#declare a XYZ variable
myXYZ = XYZ(x,y,z)

#use XYZ to define a reference point
refPoint = doc.FamilyCreate.NewReferencePoint(myXYZ)

t.Commit()

__window__.Close()
```

#### Row of Points

We can create a row of points by incrementing coordinate values using a for loop

```import clr
from Autodesk.Revit.DB import *

doc = __revit__.ActiveUIDocument.Document

t = Transaction(doc, 'create a row of reference points')

t.Start()

#use for loop variable i to increment x and y
for i in range(0,10):
x = i * 10
y = i * 10
z = 0

myXYZ = XYZ(x,y,z)
refPoint = doc.FamilyCreate.NewReferencePoint(myXYZ)

t.Commit()

__window__.Close()
```

#### Grid of Points

We can create a grid of points by incrementing coordinate values within a nested for loop

```import clr
from Autodesk.Revit.DB import *

app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document

t = Transaction(doc, 'create a grid of reference points')

t.Start()

for i in range(0,10):
#use a nested for loop variable j to increment x by i and y by j.
for j in range(0,10):
x = i * 10
y = j * 10
z = 0

myXYZ = XYZ(x,y,z)
refPoint = doc.FamilyCreate.NewReferencePoint(myXYZ)

t.Commit()

__window__.Close()
```

#### Sine Wave Points

The point array can have even more complexity to it by changing variable z with a sine and cosine formula. Please note the import of the math library to use these functions.

```import clr
import math
from Autodesk.Revit.DB import *

app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document

t = Transaction(doc, 'create wave points')

t.Start()

for i in range(0,30):
for j in range(0,30):
x = i * 10
y = j * 10
#changing z position according to cosine and sine formula
z = (10*math.cos(i)) + (10*math.sin(j))

myXYZ = XYZ(x,y,z)
refPoint = doc.FamilyCreate.NewReferencePoint(myXYZ)

t.Commit()

__window__.Close()
```