Option Explicit
'Script written by <insert name>
'Script copyrighted by <insert company name>
'Script version 2013年6月10日 21:18:57
Call Main()
Sub Main()
Const rhObjectSurface = 8
Dim strObject, arrMP,aa,line,vector,line1,plane,str,text,h,d,ptend,ptstart
Dim int,angle,vector1
d = 10 '文字大小
h = 0.5 '调节文字超出曲面距离
strObject = Rhino.GetObject("Select a surface", rhObjectSurface)
If IsNull(strObject) Then Exit Sub
str = rhino.GetString("请输入铝板编号:", "编号")
If Not IsNull(strObject) Then
arrMP = Rhino.SurfaceAreaCentroid(strObject)
If IsArray(arrMP) Then
aa = Rhino.PullPoints(strObject, arrMP)
line = rhino.AddLine(arrmp(0), aa(0))
line1 = Rhino.ExtendCurveLength(line, 0, 1, h)
Rhino.HideObject line1
ptend = rhino.CurveEndPoint(line1)
ptstart = rhino.CurveStartPoint(line1)
vector1 = rhino.VectorCreate(ptend, ptstart)
vector = rhino.VectorCreate(ptend, ptstart)
plane = Rhino.PlaneFromNormal(rhino.CurveEndPoint(line1), vector)
text = rhino.AddText(str, plane, d)
Do
int = rhino.GetInteger("确定(0),旋转文字(1),翻转文字(2),取消翻转文字(3)", 0)
If int = 1 Then
angle = (rhino.getreal("输入旋转角度", "0.0")) '/ 180 * (rhino.PI)
rhino.Print angle
plane = Rhino.RotatePlane(Plane, angle, vector1)
rhino.DeleteObject text
text = rhino.AddText(str, plane, d)
Else
If int = 2 Then
vector = rhino.VectorCreate(ptstart, ptend)
plane = Rhino.PlaneFromNormal(rhino.CurveEndPoint(line1), vector)
rhino.DeleteObject text
text = rhino.AddText(str, plane, d)
Else
If int = 3 Then
vector = rhino.VectorCreate(ptend, ptstart)
plane = Rhino.PlaneFromNormal(rhino.CurveEndPoint(line1), vector)
rhino.DeleteObject text
text = rhino.AddText(str, plane, d)
Else
If int = 0 Then
Exit Sub
End If
End If
End If