-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy pathReadSphereFile.rvb
46 lines (37 loc) · 1.29 KB
/
ReadSphereFile.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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ReadSphereFile.rvb -- April 2010
' 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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sample data:
' 0.0,0.0,0.0,4.0,0
' 10.0,0.0,0.0,4.0,255
' 10.0,10.0,0.0,4.0,65280
' 0.0,10.0,0.0,4.0,16711680
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ReadSphereFile()
Dim filename, data, i
Dim p(2), r, c, sphere
filename = Rhino.OpenFileName("Open", "Spheres Files (*.txt)|*.txt||")
If IsNull(filename) Then Exit Sub
data = Rhino.ReadDelimitedFile(filename)
If IsNull(data) Then Exit Sub
Call Rhino.EnableRedraw(False)
For i = 0 To UBound(data, 1)
If UBound(data, 2) = 4 Then
p(0) = data(i, 0) ' x coord
p(1) = data(i, 1) ' y coord
p(2) = data(i, 2) ' z coord
r = data(i, 3) ' radius
c = data(i, 4) ' rgb color
sphere = Rhino.AddSphere(p, r)
If Not IsNull(sphere) Then
Call Rhino.ObjectColor(sphere, c)
End If
End If
Next
Call Rhino.EnableRedraw(True)
End Sub