Arc Orientation, clockwise or counterclockwise

How can I get the orientation of an arc with Python?
like rs.ArcOrientation()


I have meet a similar question like yours,you can check this link:

the answer maybe can figure your Question

Thanks for your reply, grasshopper don’t help me.

One of the problems here is that the orientation of a planar curve depends on a reference plane. You can imagine that if you have a ‘clockwise’ arc viewed from, say the Front ortho view, if you look at it from the back, it will be ‘counterclockwise’. So what is the reference plane you would like to use?

Curves like arcs may be easy to resolve relative to a given reference plane, but arbitrary curves may have ambiguous directions - imagine a figure eight, half of it is clockwise, half of it is counterclockwise…

ok, in my case reference is only the view from the top. how can i solve it with this plane?

Maybe something like this will work for you? It is set up to only work with arcs that are in the current active CPlane.

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def arc_filt(rhino_object, geometry, component_index):
    return geometry.IsArc()
def ArcDirection():
    msg="Select arc to check direction"
    if not arcID: return
    if Rhino.RhinoMath.EpsilonEquals(angle,180,atol): arc_dir="Clockwise"
    elif Rhino.RhinoMath.EpsilonEquals(angle,0,atol): arc_dir="Counterclockwise"
    else: arc_dir="Unable to be determined relative to active CPlane"
    print "Arc direction: {}".format(arc_dir)

Thank you, this function works fine, if you select single arcs manually. For automatic check of segments of polylines in a loop it don’t help me. I need something like this:
given: polyline(line, arc, arc, line, arc, line)

l_arc_direction = []    
for segment in polyline:
    arc_dir = ArcDirection(object_id, segment)
return l_arc_direction

wish for result:
print(l_arc_direction) => ['noarc','clockwise','counterclockwise','noarc','clockwise','noarc']

But i have no idea how to iterate the segments of a polyline.
Is this possible?

hi @carsten.hilbert

With a little modification of @Helvetosaur’s script, you can try this:

polycurve = rs.GetObject("Select polycurves" , rs.filter.curve)
curves = rs.ExplodeCurves(polycurve)
for c in curves:
    if isinstance(rs.coercegeometry(c),  Rhino.Geometry.ArcCurve):

print dir #list containing the result
rs.DeleteObjects(curves) #optionally delete the exploded curves (1.2 KB)

Thanks a lot!
Function from @Helvetosaur with modification from @DavidLeon works perfect.