Arc Orientation, clockwise or counterclockwise

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

Thanks

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


#arcs
def arc_filt(rhino_object, geometry, component_index):
    return geometry.IsArc()
    
def ArcDirection():
    msg="Select arc to check direction"
    arcID=rs.GetObject(msg,4,preselect=True,custom_filter=arc_filt)
    if not arcID: return
    
    atol=sc.doc.ModelAngleToleranceDegrees
    ref_plane=rs.ViewCPlane()
    arc_crv=rs.coercecurve(arcID)
    rc,arc=arc_crv.TryGetArc()
    arc_plane=arc.Plane
    angle=rs.VectorAngle(ref_plane.Normal,arc_plane.Normal)
    
    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)
ArcDirection()

@Helvetosaur
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)
    l_arc.append(arc_dir)
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)
dir=[]
for c in curves:
    if isinstance(rs.coercegeometry(c),  Rhino.Geometry.ArcCurve):
        dir.append(ArcDirection(c))
    else:
        dir.append("noarc")

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

arc_dir.py (1.2 KB)

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