本帖最后由 licml 于 2011-1-10 11:54 编辑
之前看到这里有个代码是直线段网架,一直想做个贴着曲面的网架,今天终于做出来了。但是中间有个地方需要改进(见蓝色部分),还望高人指点
Option Explicit
'Script written by <insert name>
'Script copyrighted by <insert company name>
'Script version 2011年1月7日 22:50:05
Call Main()
Sub Main()
Dim strSrf,UDomain,VDomain,dU,dV,m,n,i,j
m=rhino.GetReal("input u segment",10)
n=rhino.GetReal("input v segment",10)
strSrf=rhino.GetObject("select a surface:")
UDomain=rhino.SurfaceDomain(strSrf,0)
VDomain=rhino.SurfaceDomain(strSrf,1)
dU=(UDomain(1)-UDomain(0))/m
dV=(VDomain(1)-VDomain(0))/n
Dim Pt,strCur,strStar,arrPlane,strPara,Cir
Dim puv():ReDim puv(m,n)
Dim p():ReDim p((m+1)*(n+1)-1)
For i = 0 To m
For j = 0 To n
puv(i,j)=array(dU*i,dV*j)
p(i*(m+1)+j)=Rhino.EvaluateSurface (strSrf, puv(i,j))
p(j)=p(i*(m+1)+j)
Next
strCur=rhino.AddInterpCrvOnSrf (strSrf,array(p(0),p(1),p(2),p(3),p(4),p(5),p(6),p(7),p(8),p(9),p(10)))
'这里,怎么把p写进一个array里面,记得之前看过有只增加数据,不覆盖原数据的办法,但找不到在哪看的了
strStar=rhino.CurveStartPoint(strCur)
strPara=rhino.CurveClosestPoint(strCur,strStar)
arrPlane=rhino.CurvePerpFrame(strCur,strPara)
Cir=rhino.AddCircle(arrPlane,0.2)
rhino.addsweep1 strCur,Cir
Next
For j=0 To n
For i=0 to m
puv(i,j)=array(dU*i,dV*j)
p(i*(m+1)+j)=Rhino.EvaluateSurface (strSrf, puv(i,j))
p(i)=p(i*(m+1)+j)
Next
strCur=rhino.AddInterpCrvOnSrf (strSrf,array(p(0),p(1),p(2),p(3),p(4),p(5),p(6),p(7),p(8),p(9),p(10)))
strStar=rhino.CurveStartPoint(strCur)
strPara=rhino.CurveClosestPoint(strCur,strStar)
arrPlane=rhino.CurvePerpFrame(strCur,strPara)
Cir=rhino.AddCircle(arrPlane,0.2)
rhino.addsweep1 strCur,Cir
Next
End Sub
|