forked from mcneel/rhino-developer-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExportControlPoints.rvb
52 lines (41 loc) · 1.37 KB
/
ExportControlPoints.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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ExportControlPoints.rvb -- June 2005
' 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 ExportControlPoints
' Pick a curve object
Dim strObject
strObject = Rhino.GetObject("Select curve", 4)
If IsNull(strObject) Then Exit Sub
' Get the curve's control points
Dim arrPoints
arrPoints = Rhino.CurvePoints(strObject)
If Not IsArray(arrPoints) Then Exit Sub
' Prompt the user to specify a file name
Dim strFilter, strFileName
strFilter = "Text File (*.txt)|*.txt|All Files (*.*)|*.*||"
strFileName = Rhino.SaveFileName("Save Control Points As", strFilter)
If IsNull(strFileName) Then Exit Sub
' Get the file system object
Dim objFSO, objStream
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Open a text file to write to
On Error Resume Next
Set objStream = objFSO.CreateTextFile(strFileName, True)
If Err Then
MsgBox Err.Description
Exit Sub
End If
' Write each point as text to the file
Dim strPoint, strText
For Each strPoint In arrPoints
strText = Rhino.Pt2Str(strPoint)
objStream.WriteLine(strText)
Next
' Close the file
objStream.Close
End Sub
ExportControlPoints