2008年11月10日 星期一

Rhino Script Excise05



Option Explicit
'Script written by David Rutten
'Script copyrighted by Robert McNeel & Associates
'Script version 2008年11月10日 下午 09:50:44

Call IterativeShortenCurve()
Sub IterativeShortenCurve()
Dim strCurveID : strCurveID = Rhino.GetObject("Open curve to smooth", 4, True)
If IsNull(strCurveID) Then Exit Sub
If Rhino.IsCurveClosed(strCurveID) Then Exit Sub

Dim dblMin, dblMax, dblGoal
dblMin = Rhino.Distance(Rhino.CurveStartPoint(strCurveID), Rhino.CurveEndPoint(strCurveID))
dblMax = Rhino.CurveLength(strCurveID)
dblGoal = Rhino.GetReal("Goal Length", 0.5*(dblMin + dblMax), dblMin, dblMax)
If IsNull(dblGoal) Then Exit Sub

Do Until Rhino.CurveLength(strCurveID) < dblGoal
Call Rhino.EnableRedraw(False)
strCurveID = SmoothCurve(StrCurveID, 0.1)
If IsNull(strCurveID) Then Exit Do
Call Rhino.EnableRedraw(True)
Loop
End Sub

沒有留言: