ArrayPointsOnSurface

The following example demonstrates how to array point objects on a surface.

Example

Option Explicit

'------------------------------------------------------------------------------

' Subroutine: ArrayPointsOnSurface

' Purpose:    Creates an array of points on a surface.

'------------------------------------------------------------------------------

Sub ArrayPointsOnSurface()

Dim strObject, nRows, nColumns

Dim U, V, i, j, arrParam(1), arrPoint

' Get the surface object

strObject = Rhino.GetObject("Select surface", 8)

If IsNull(strObject) Then Exit Sub

' Get the number of rows

nRows = Rhino.GetInteger("Number of rows", 2, 2)

If IsNull(nRows) Then Exit Sub

nRows = nRows - 1

' Get the number of columns

nColumns = Rhino.GetInteger("Number of columns", 2, 2)

If IsNull(nColumns) Then Exit Sub

nColumns = nColumns - 1

' Get the domain of the surface

U = Rhino.SurfaceDomain(strObject, 0)

V = Rhino.SurfaceDomain(strObject, 1)

If Not IsArray(U) or Not IsArray(V) Then Exit Sub

' Add the points

For i = 0 to nRows

arrParam(0) = U(0) + (((U(1) - U(0)) / nRows) * i)

For j = 0 to nColumns

arrParam(1) = V(0) + (((V(1) - V(0)) / nColumns) * j)

arrPoint = Rhino.EvaluateSurface(strObject, arrParam)

If IsArray(arrPoint) Then Rhino.AddPoint arrPoint

Next

Next

End Sub