#SelectSurfaceCornerGrips
import rhinoscriptsyntax as rs
srf = rs.GetSurfaceObject('Select a surface for corner point display', preselect=True)
if srf:
srf = srf [0]
srfPtCount = rs.SurfacePointCount(srf)
uCount = srfPtCount [0]
vCount = srfPtCount [1]
srfPtCount = uCount*vCount
#Report the total number of points, Yes/No option?
def PrintSurfacePointCount():
print "Point Count: " + (str(srfPtCount))
print "U Count: " + str(uCount)
print "V Count: " + str(vCount)
def SelectSurfaceCornerGrips(srf):
#u is a row index, with a total of 'v' points, Corners at (u0, u1, u2, u3)
u1index = uCount-1 # Zero based, final point of first row
u3index = srfPtCount-1 #Zero based, final point of the surface
rs.EnableObjectGrips(srf)
u0 = rs.SelectObjectGrip(srf, 0)
u3 = rs.SelectObjectGrip(srf, u3index)
u1 = rs.SelectObjectGrip(srf, vCount-1)
u2 = rs.SelectObjectGrip(srf, srfPtCount-vCount)
p0 = rs.ObjectGripLocation(srf, 0)
p1 = rs.ObjectGripLocation(srf, u3index)
p2 = rs.ObjectGripLocation(srf, vCount-1)
p3 = rs.ObjectGripLocation(srf, srfPtCount-vCount)
points = (p0, p1, p2, p3)
return points
SelectSurfaceCornerGrips(srf)
print points
if points:
rs.AddPoints(points)
PrintSurfacePointCount()
#Option for Creating Points VS Selecting the Points
#Will it work for 3 sided surfaces?
I’m trying to clean up some of my early code trials and learning by trying functions. I thought I was using return properly, to return the result of some arguments in my function SelectSurfaceCornerGrips function to use later on. In return points
and then print points
, it becomes clear I haven’t used it correctly. It worked before anyway as a line by line piece of code, so I’ve kind of taken a step backwards by adding the functions, for now.
Any help appreciated!