在Rhino中运行脚本提示 类型不匹配:'ubound'
点击选择了一个点后就会提示 类型不匹配:'ubound'
以下是源代码:
option explicit
'Script by Frank
sub main()
dim arrObjects, arrCoords
dim arrAverage(2)
dim i, sumX, sumY, sumZ
arrObjects = Rhino.GetObject("Select points", 1, ,vbTrue)
if IsNull(arrObjects) then exit sub
sumX = 0
sumY = 0
sumZ = 0
for i = 0 to Ubound(arrObjects)
arrCoords = Rhino.PointCoordinates(arrObject(i))
sumX = sumX + arrCoords(0)
sumY = sumY + arrCoords(1)
sumZ = sumZ + arrCoords(2)
next
arrAverage(0) = sumX / (Ubound(arrObjects) + 1)
arrAverage(1) = sumY / (Ubound(arrObjects) + 1)
arrAverage(2) = sumZ / (Ubound(arrObjects) + 1)
Rhino.Print "Average:" & Rhino.Pt2Str(arrAverage, 3)
Rhino.AddTextDot "Centroid", arrAverage
end sub
main