forked from mcneel/MOVED-rhinoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DivideCurveDashed.rvb
59 lines (43 loc) · 1.48 KB
/
DivideCurveDashed.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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DivideCurveDashed.rvb -- October 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 and 5.0.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Divides a curve into "dashed" segments
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub DivideCurveDashed
Dim curve, slength, dlength
Dim i, length, pt, t, dom, results
curve = Rhino.GetObject("Select curve to divide", 4, True)
If IsNull(curve) Then Exit Sub
slength = Rhino.GetReal("Segment length", 1.0)
If IsNull(slength) Then Exit Sub
If (slength <= 0) Then Exit Sub
dlength = Rhino.GetReal("Dash length", 1.0)
If IsNull(dlength) Then Exit Sub
If (dlength <= 0) Then Exit Sub
Call Rhino.EnableRedraw(False)
i = 0
Do
If (i Mod 2 = 0) Then
length = slength
Else
length = dlength
End If
pt = Rhino.CurveArcLengthPoint(curve, length)
If IsNull(pt) Then Exit Do
t = Rhino.CurveClosestPoint(curve, pt)
If (i Mod 2 = 0) Then
results = Rhino.SplitCurve(curve, t, True)
curve = results(1)
Else
dom = Rhino.CurveDomain(curve)
curve = Rhino.TrimCurve(curve, Array(t, dom(1)), True)
End If
i = i + 1
Loop While True
Call Rhino.EnableRedraw(True)
End Sub