Curve direction


This is a simple example script from python to flip the curve direction:

import rhinoscriptsyntax as rs

def CurveDirection():
    master = rs.AddCurve(([0,0,0],[0,100,0],[100,100,0],[100,0,0],[0,0,0]))
    curves = rs.GetObjects("Select closed curves to set directions CW",4)
    for curve in curves:
        if rs.IsCurvePlanar(curve) and rs.IsCurveClosed(curve):
            if rs.CurveDirectionsMatch(curve, master):
                print "Curve direction allready CW"        
                print "Curve direction flipped"
            print "Curve not closed or planar"

I discovered that there is a difference in python for the CW or CCW direction of a closed curve and the “world” normal direction.

With rs.ReverseCurve the direction is changed, but when I have two curves with a rs.CurveNormal of (0,0-1) and two with (0,0,1) the curves don’t have the same CW or CCW direction.

  1. So is it true that I have the set all Normal the same and than check the direction?
  2. How do I get all normals the same? (rs.CurveNormal does only return the normal)
  3. How do I get rid of the physical master curve?



ok… all my questions are answered with:


but, I’am still wondering why the first method didn’t work…