Basic Point Addition

import Rhino
import rhinoscriptsyntax as rs

crv = rs.GetObject()
pts = rs.BoundingBox(crv)

print pts
print "Point 1 is " + str(pts[0])
print "Point 2 is " + str(pts[1])

pointAdd = Rhino.Geometry.Point3d(0,0,0)

pointAdd = pointAdd.Add(pointAdd, pts[0])
print "Origin + Point 1 is " + str(pointAdd)

pointAdd = pointAdd.Add(pointAdd, pts[1])
print "Point 1 + Point 2 is " + str(pointAdd)


for i in pts:
    pointAdd += pointAdd.Add(pointAdd, (pts[i]))

print pointAdd

Message: expected index value, got Point3d

Sorry… really basic one here. I don’t see where it’s expecting an index. At least, where it’s expecting an index I’m giving it one. Trying to get the centroid of a Bounding box. I was having some issues with ‘type’ earlier too. I think I’m just not treating methods/properties right.

All the print statements were just me checking I was at least doing the addition right. It’s the for loop which I’ve not defined very well.

for i in pts: #i is a Point3d, not an index
    pointAdd += pointAdd.Add(pointAdd, i)

To calculate a centroid of the bounding box:

import Rhino
import rhinoscriptsyntax as rs

crv = rs.GetObject()
pts = rs.BoundingBox(crv)

pointAdd = Rhino.Geometry.Point3d(0,0,0)

for i in pts:
    pointAdd = pointAdd.Add(pointAdd, i)

pointAdd /= len(pts)
rs.AddPoint(pointAdd)

Thanks Menno!

Not sure why I ended up going with the increment approach… this basically ended up adding an unecessary factor of pointAdd at each step of the for loop, which of course kept increasing anyway, I think?