-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy pathGetYCoordinate.rvb
54 lines (41 loc) · 1.54 KB
/
GetYCoordinate.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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' GetYCoordinate.rvb -- September 2009
' 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 GetYCoordinate
' Declare local variables
Dim crv, box, x, p0, p1, line, ccx, i
' Select a curve object and make sure it is planar
' Note, this code assumes the curve is planar with
' the world x-y plane.
crv = Rhino.GetObject("Select planar curve", 4, True)
If IsNull(crv) Then Exit Sub
If Rhino.IsCurvePlanar(crv) = False Then Exit Sub
' Get the curve's bounding box
box = Rhino.BoundingBox(crv)
' Prompt for an x-axis coordinate value.
x = Rhino.GetReal("X-coordinate to evaluate", , box(0)(0), box(2)(0))
If IsNull(x) Then Exit Sub
' Hide our dirty work...
Call Rhino.EnableRedraw(False)
' Create a line curve that intesects the curve
' along the y-axis
p0 = Array(x, box(0)(1), 0)
p1 = Array(x, box(2)(1), 0)
line = Rhino.AddLine(p0, p1)
' Calculate the intesection between the two curves
ccx = Rhino.CurveCurveIntersection(crv, line)
Call Rhino.DeleteObject(line)
' If one or more intersections were found,
' print the results
If IsArray(ccx) Then
For i = 0 To UBound(ccx)
Rhino.Print "Point(" & CStr(i) & ") = " & Rhino.Pt2Str(ccx(i,1))
Next
End If
' Make sure to turn redrawing back on
Call Rhino.EnableRedraw(True)
End Sub