generative modeling for Rhino
(I uploaded the wrong script file, so I just re-uploaded the right one. Sorry for inconvenience!)
I am working on the script, which generates orthogonal grids based on a given surface.
The script simply finds the bounding box points of the surface, generates base grid points from them and makes contouring lines based on the base grid points with world ZX or YZ plane.
My problem here is that the results of the script are unpredictable because the script frequently misses the first or the last contouring lines. It seems that the position or domain ranges of the given surface matters.
How can I make sure that the script always includes both ends, using bounding box points and AddSrfContourCrvs?
In advance, thank for your help!
import rhinoscriptsyntax as rs def contourPointsPlane(srf, pts, plane=rs.WorldYZPlane()):
"returns the list of the crvs list, divided by grid points"
listCrvs = list() for i in range(0, len(pts)):
tempPlane = rs.MovePlane(plane, pts[i])
tempCrvs = [rs.AddSrfContourCrvs( srf, tempPlane)]
listCrvs.extend ( tempCrvs )
def getIntervalPts(startPt, endPt, num):
"returns the list of dividing points"
vecDir = rs.VectorUnitize(rs.VectorCreate( endPt ,startPt ) )
dblDist = rs.Distance(endPt, startPt)
distance = dblDist/num
maxIndex = dblDist / distance
vecDir = rs.VectorScale(vecDir, distance )
ptList = [startPt] #assign the start point to the first
for i in range( 1, int(maxIndex)):
ptList.append( rs.PointAdd( ptList[i-1], vecDir ) )
ptList.append(endPt) #assign the end point to the last
if __name__== "__main__":
srf = rs.GetObject("select the surface")
bBox = rs.BoundingBox(srf)
ptsX = getIntervalPts(bBox, bBox, 10)
ptsY = getIntervalPts(bBox, bBox, 10)
crvTopXListList = (contourPointsPlane( srf, ptsX, rs.WorldYZPlane() ) )
crvTopYListList = (contourPointsPlane( srf, ptsY, rs.WorldZXPlane()) )
no advice? :'
This is answered here:
Thx a lot Giulio! I posted a reply at the python forum. Please see it if you don't mind!