Grasshopper

algorithmic modeling for Rhino

Hey guys, 

any idea how to sort a list of curves in python? key is X value of start point.

It seems python in grasshopper doesn't support AddTextDot. . . 

any solution!!!

THX,

Views: 781

Replies to This Discussion

http://wiki.python.org/moin/HowTo/Sorting/

Assuming that your input is a list a curves named 'curves'...

sorted_curves = sorted(curves, key=lambda a: a.PointAtStart.X)

Thx,I did something like this:

def midPointX(crv):
    domain=rs.CurveDomain(crv)
    midpoint=rs.EvaluateCurve(crv,(domain[0]+domain[1])/2)
    return (midpoint.X*100)

a=sorted(curves,key=midPointX)

and its working to. 

Thanks again for help,

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service