-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFlowAlongSrf.rvb
68 lines (48 loc) · 1.77 KB
/
FlowAlongSrf.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
56
57
58
59
60
61
62
63
64
65
66
67
68
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' FlowAlongSrf.rvb -- October 2008
' 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 TestFlowAlongSrf
Dim arrObjects, strBase, strTarget, arrResults
arrObjects = Rhino.GetObjects("Select objects to flow along a surface")
If IsNull(arrObjects) Then Exit Sub
strBase = Rhino.GetObject("Base surface", 8)
If IsNull(strBase) Then Exit Sub
strTarget = Rhino.GetObject("Target surface", 8)
If IsNull(strTarget) Then Exit Sub
arrResults = DoFlowAlongSrf(arrObjects, strBase, strTarget)
If IsArray(arrResults) Then
For i = 0 To UBound(arrResults)
Rhino.Print arrResults(i)
Next
End If
End Sub
Function DoFlowAlongSrf(arrObjects, strBase, strTarget)
' Declare local variables
Dim saved, cmd
' For speed, turn of screen redrawing
Rhino.EnableRedraw False
' Save any selected objects
saved = Rhino.SelectedObjects
' Unselect all objects
Rhino.UnSelectAllObjects
' Select the brep
Rhino.SelectObjects arrObjects
' Script the split command
cmd = "_FlowAlongSrf _SelID " & strBase & " _SelID " & strTarget
Rhino.Command cmd, 0
' By preselecting the brep, the results of
' Split will be selected. So, get the selected
' objects and return them to the caller.
DoFlowAlongSrf = Rhino.SelectedObjects
' Unselect all objects
Rhino.UnSelectAllObjects
' If any objects were selected before calling
' this function, re-select them
If IsArray(saved) Then Rhino.SelectObjects(saved)
' Don't forget to turn redrawing back on
Rhino.EnableRedraw True
End Function