forked from mcneel/rhino-developer-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExplodePolyCurve.rvb
38 lines (28 loc) · 963 Bytes
/
ExplodePolyCurve.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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ExplodePolyCurve.rvb -- November 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
Sub ExplodePolyCurve
Dim curve, i, seg, seg_count
Dim point, bound, curve_t()
curve = Rhino.GetObject("Select polycurve to explode", 4, True)
If IsNull(curve) Then Exit Sub
If Not Rhino.IsPolyCurve(curve) Then Exit Sub
seg_count = Rhino.PolyCurveCount(curve)
If Rhino.IsCurveClosed(curve) Then
seg = 0
Else
seg = 1
End If
bound = 0
For i = seg To seg_count - 1
point = Rhino.CurveStartPoint(curve, i)
ReDim Preserve curve_t(bound)
curve_t(bound) = Rhino.CurveClosestPoint(curve, point)
bound = bound + 1
Next
Call Rhino.SplitCurve(curve, curve_t, True)
End Sub