-
Notifications
You must be signed in to change notification settings - Fork 335
/
Copy pathAutoAnnotateNamedCurves.rvb
36 lines (28 loc) · 1.07 KB
/
AutoAnnotateNamedCurves.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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' AutoAnnotateNamedCurves.rvb -- March 2015
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 5.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Sub AutoAnnotateNamedCurves
Dim arrCurves, strCurve, strName
Dim arrPt3d, arrPt2d, arrPlane, arrX, arrY, arrZ
arrCurves = Rhino.GetObjects("Select named curves to annotate", 4, True, True)
If IsNull(arrCurves) Then Exit Sub
Call Rhino.EnableRedraw(False)
arrPlane = Rhino.ViewCPlane
arrZ = arrPlane(3)
For Each strCurve In arrCurves
strName = Rhino.ObjectName(strCurve)
If Not IsNull(strName) Then
arrPt3d = Rhino.CurveMidPoint(strCurve)
arrPt2d = Rhino.CurveClosestPoint(strCurve, arrPt3d)
arrX = Rhino.CurveTangent(strCurve, arrPt2d)
arrY = Rhino.VectorCrossProduct(arrZ, arrX)
arrPlane = Rhino.PlaneFromFrame(arrPt3d, arrX, arrY)
Call Rhino.AddText(strName, arrPlane)
End If
Next
Call Rhino.EnableRedraw(True)
End Sub