forked from mcneel/MOVED-rhinoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExportSurfacePoints.rvb
55 lines (44 loc) · 1.45 KB
/
ExportSurfacePoints.rvb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ExportSurfacePoints.rvb -- May 2004
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Sub ExportSurfacePoints()
Const rhObjectSurface = 8
' Pick a surface object
Dim strSurface
strSurface = Rhino.GetObject("Select surface to export control points", rhObjectSurface)
If IsNull(strSurface) Then Exit Sub
' Get the surface control points
Dim arrPoints, arrPt
arrPoints = Rhino.SurfacePoints(strSurface)
If Not IsArray(arrPoints) Then Exit Sub
' Prompt for a filename
Dim strFileName, strFilter
strFilter = "CSV File (*.csv)|*.csv|All Files (*.*)|*.*||"
strFileName = Rhino.SaveFileName("Save Control Points As", strFilter)
If IsNull(strFileName) Then Exit Sub
' Create a file system object
Dim objFSO, objStream
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Create a new text file
On Error Resume Next
Set objStream = objFSO.CreateTextFile(strFileName, True)
If Err Then
MsgBox Err.Description
Exit Sub
End If
' Write each surface point
Dim strPoint
For Each arrPt In arrPoints
strPoint = Rhino.Pt2Str(arrPt)
objStream.WriteLine(strPoint)
Next
' Close the file stream
objStream.Close
' Cleanup
Set objStream = Nothing
Set objFSO = Nothing
End Sub