标题: RS的数组好像有点绕人,清高手指教 [打印本页] 作者: attention412 时间: 2010-8-8 21:01 标题: RS的数组好像有点绕人,清高手指教 Sub yudi()
Dim i:i=0
Dim arrpt(2)
Dim r:r=getinteger("number of interger",16,2)
Dim j:j=getinteger("number of interger",1,1)
For h=0 To 2
Dim pi:pi =Rhino.pi
Dim arrpoints(11)
For i=0 To 2
arrpt(0)=(r+h*0.04)*Cos(i*2/3*pi)
arrpt(1)=(r+h*0.04)*Sin(i*2/3*pi)
arrpt(2)=h*j
arrpoints(0+i)=Rhino.addpoint(arrpt)
arrpt(0)=((r+h*0.04)-((40-h)*0.05))*Cos(i*2/3*pi+1/6*pi)
arrpt(1)=((r+h*0.04)-((40-h)*0.05))*Sin(i*2/3*pi+1/6*pi)
arrpt(2)=h*j
arrpoints(1+i)=Rhino.addpoint(arrpt)
arrpt(0)=((r+h*0.04)-(40-h)*0.15)*Cos(i*2/3*pi+1/3*pi)
arrpt(1)=((r+h*0.04)-(40-h)*0.15)*Sin(i*2/3*pi+1/3*pi)
arrpt(2)=h*j
arrpoints(2+i)=Rhino.addpoint(arrpt)
arrpt(0)=((r+h*0.04)-(40-h)*0.05)*Cos(i*2/3*pi+1/2*pi)
arrpt(1)=((r+h*0.04)-(40-h)*0.05)*Sin(i*2/3*pi+1/2*pi)
arrpt(2)=h*j
arrpoints(3+i)=Rhino.addpoint(arrpt)
Next
If IsArray(arrPoints) Then
Rhino.AddInterpCurve arrpoints
Else Rhino.print("error")
End If
Option Explicit
'Script written by <insert name>
'Script copyrighted by <insert company name>
'Script version Sunday, 08 August 2010 22:34:25
Call Main()
Sub main()
Dim arrpt(2)
Dim r:r=getinteger("number of interger",16,2)
Dim j:j=getinteger("number of interger",1,1)
Dim i,h
Dim k:k=0
Dim pi:pi =Rhino.pi
Dim arrpoints(12)
For h=0 To 2
For i=0 To 2
arrpt(0)=(r+h*0.04)*Cos(i*2/3*pi)
arrpt(1)=(r+h*0.04)*Sin(i*2/3*pi)
arrpt(2)=h*j
arrpoints(k)=arrpt
arrpt(0)=((r+h*0.04)-((40-h)*0.05))*Cos(i*2/3*pi+1/6*pi)
arrpt(1)=((r+h*0.04)-((40-h)*0.05))*Sin(i*2/3*pi+1/6*pi)
arrpt(2)=h*j
arrpoints(k+1)=arrpt
arrpt(0)=((r+h*0.04)-(40-h)*0.15)*Cos(i*2/3*pi+1/3*pi)
arrpt(1)=((r+h*0.04)-(40-h)*0.15)*Sin(i*2/3*pi+1/3*pi)
arrpt(2)=h*j
arrpoints(k+2)=arrpt
arrpt(0)=((r+h*0.04)-(40-h)*0.05)*Cos(i*2/3*pi+1/2*pi)
arrpt(1)=((r+h*0.04)-(40-h)*0.05)*Sin(i*2/3*pi+1/2*pi)
arrpt(2)=h*j
arrpoints(k+3)=arrpt
k=k+4
Next
If IsArray(arrPoints) Then
arrpoints(12)=array(r+h*0.04,0,h*j)
Rhino.AddInterpCurve arrpoints
rhino.AddPoints arrpoints
k=0
Else Rhino.print("error")
End If
Next
End Sub作者: attention412 时间: 2010-8-9 19:40
知道问题所在了,谢谢楼上的热心,不过你解释的“addpoint不是把一个点加到数组里 而是画点”倒不是很正确,可以同时赋值的,我只是数组的数量出了点问题,可能不知道目的而去揣摩别人的程序的确不易。再次感谢作者: claudemit 时间: 2010-8-9 20:24 本帖最后由 claudemit 于 2010-8-10 04:38 编辑