Grasshopper

algorithmic modeling for Rhino

[rhino python] precision problem in using AddSrfContourCrvs (updated)

Hi,

 

(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!
-Ki

 


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()) )

Views: 791

Attachments:

Replies to This Discussion

Hi people,

no advice?  :'  

This is answered here:
http://python.rhino3d.com/threads/953-rhino-python-precision-proble...

Thanks,

- Giulio
________________
giulio@mcneel.com

Thx a lot Giulio! I posted a reply at the python forum. Please see it if you don't mind!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service