标题: 问一个关于evaluatecurve的问题 [打印本页] 作者: ninesuns 时间: 2011-12-17 16:44 标题: 问一个关于evaluatecurve的问题 经过不懈努力,终于看完了101的上篇,虽然好多东西还不是很懂,不过也算是把面向过程看完了。怀着激动的心情开始看下篇,刚开始就遇到了问题。希望高手们能解答一下。下面上代码:
Call main()
Sub main()
Dim strcurveid
strcurveid=rhino.GetObject("select a curve to sample",4,True,True)
If isnull(strcurveid) Then Exit Sub
Dim t
Call rhino.EnableRedraw(False)
For t=0.0 To 1.0 Step 0.002
Call addpointatr1parameter(strcurveid,t)
Next
Call rhino.EnableRedraw(True)
End Sub
Function addpointatr1parameter(strcurveid,dblunitparameter)
addpointatr1parameter=Null
Dim crvdomain
crvdomain=rhino.CurveDomain(strcurveid)
If isnull(crvdomain) Then Exit Function
Dim dblr1param
dblr1param=crvdomain(0)+dblunitparameter*(crvdomain(1)-crvdomain(0))
Dim arrr3point
arrr3point=rhino.EvaluateCurve(strcurveid,dblr1param)
If Not isarray(arrr3point) Then Exit Function
Dim strpointid
strpointid=rhino.AddPoint(arrr3point)
Call rhino.ObjectColor(strpointid,parametercolour(dblunitparameter))
addpointatr1parameter=strpointid
End Function
Function parametercolour(dblparam)
Dim redcomponent
redcomponent=255*dblparam
If(redcomponent<0) Then redcomponent=0
If(redcomponent>255) Then redcomponent=255
parametercolour=rgb(redcomponent,0,255-redcomponent)
End Function