Option Explicit 'Script written by Ted Ngai Apr 2008 'This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License. 'http://creativecommons.org/licenses/by-sa/3.0/us/ Call ReadPts() Sub ReadPts() Dim strFilter, strFileName strFilter = "Text File (*.txt)|*.txt|All Files (*.*)|*.*||" strFileName = Rhino.OpenFileName("Open Point File", strFilter) If IsNull(strFileName) Then Exit Sub Dim objFSO, objFile, objFileCC Set objFSO = CreateObject("Scripting.FileSystemObject") On Error Resume Next Set objFile = objFSO.OpenTextFile(strFileName, 1) Set objFileCC = objFSO.OpenTextFile(strFileName, 1) If Err Then MsgBox Err.Description Exit Sub End If 'Read all the numbers into an array Dim txt, a txt = objFile.ReadAll a = Split(txt,",") If Not IsArray(a) Then Exit Sub 'Rhino.Print Ubound(a) 'Rhino.Print a(0) 'Check for number of columns Dim col, row, b row = 1 b = objFileCC.ReadLine col = Split(b,",") 'Check for number of rows Do While objFileCC.AtEndOfStream <> True objFileCC.SkipLine row = row+1 Loop Rhino.Print "U : " & Ubound(col) Rhino.Print "V : " & row 'create points Dim u,v, x, y, z, n,nMax, arrPoints() 'Find max value Dim aMax, aTemp, k ReDim aTemp(row*Ubound(col)-1) k = 0 For v = 1 To row For u = 1 To Ubound(col) aTemp(k) = CDbl(a(k)) k = k+1 Next Next aMax = Rhino.SortNumbers(aTemp, False) 'assign value to x,y,z n = 0 nMax = row*Ubound(col) ReDim arrPoints(nMax-1) 'Call Rhino.EnableRedraw(False) For v = 1 To row For u = 1 To Ubound(col) 'Scale the u v points or apply mathematical other functions to transform the points x=10*u y=10*v z=(CDbl(a(n))/aMax(0)*50)-55 arrPoints(n) = array(x,y,z) n = n+1 Next Next Dim UVcount(1) UVcount(0) = Ubound(col) UVcount(1) = row If Ubound(col) > 1 And row > 1 Then Rhino.AddsrfPtGrid UVcount,arrPoints Else Rhino.Print "Cannot make surface" End If 'Call Rhino.EnableRedraw(True) objFile.Close Set objFile = Nothing Set objFSO = Nothing End Sub