It’s not “the intricacies of GHPython” that stop me, I can always find answers to Python questions. It’s the Rhino APIs that trip me up time after time.
Thanks for your advice but as this comparison demonstrates, all efforts have failed so far.
The white group (“Show Curve Direction”) has three different methods to display curve direction and they always agree. The six Raw Crvs consist of four clockwise curves and two counterclockwise.
flip_crv_Python_2021_Jul24b.gh (20.0 KB)
The only thing that works as expected is the C# (green group) from @Baris which returns all curves with CCW direction.
The Python versions just flip all the curves. What’s wrong? (that’s putting it mildly…)
pyCW1 source:
if crv.ClosedCurveOrientation(P) == 'Clockwise':
CW = crv
CCW = crv.Duplicate()
CCW.Reverse()
else:
CCW = crv
CW = crv.Duplicate()
CW.Reverse()
pyCW2 source:
CW = crv
CCW = crv.Duplicate()
CCW.Reverse()
if crv.ClosedCurveOrientation(P) != 'Clockwise':
CW = CCW
CCW = crv
pyCW3 source:
import rhinoscriptsyntax as rs
crv_id = rs.coercecurve(crv)
if crv.ClosedCurveOrientation(P) == 'Clockwise':
CW = crv
CCW = rs.ReverseCurve(crv_id)
else:
CW = rs.ReverseCurve(crv_id)
CCW = crv
C# source:
if(crv.ClosedCurveOrientation(plane) == CurveOrientation.Clockwise) crv.Reverse();
A = crv;