Results 1 to 7 of 7

Thread: [rhino python] precision problem in using AddSrfContourCrvs

Threaded View

  1. #1

    [rhino python] precision problem in using AddSrfContourCrvs

    Hi,

    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 AddSrfContourCrvs?

    In advance, thank for your help!







    Code:
    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 )
    
        return  listCrvs 
    
    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 
    
    return ptList
    
    if __name__== "__main__":
    
    srf = rs.GetObject("select the surface")
    
    bBox = rs.BoundingBox(srf)
        ptsX = getIntervalPts(bBox[0], bBox[1], 10) 
    
        ptsY = getIntervalPts(bBox[0], bBox[3], 10) 
    
        crvTopXListList = (contourPointsPlane( srf, ptsX, rs.WorldYZPlane() ) )
    
        crvTopYListList = (contourPointsPlane( srf, ptsY, rs.WorldZXPlane()) )
    Attached Files
    Last edited by noclew; 03-20-2012 at 05:11 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts