Closed curve - Identifying if draw order is clockwise or anti-clockwise?

I have a script that creates a closed curve of the outline of any number of selected closed curves - the perimeter of the whole compound object as it were. I then want to know if the perimeter closed curve has a clockwise or anti-clockwise drawn order from point 1 to point 2 to point n. It is not always drawn consistently.

Later in the script I explode the perimeter polyline into it’s component curve elements and assign each curve to a layer based on the direction of the curve (using it’s normal). I want all the normals to be facing outward - away from the centre of the closed curve.

I have a clunky testing method at the moment, which tests if a point offset from the centre of the line is inside or outside of the original perimeter curve. But it doesn’t return consistent results with complex geometry.

Is there a way to force the original perimeter closed curve to be drawn clockwise or to test the drawn order of the perimeter object once drawn and reverse it if necessary?

Thank you all!

This method might work for you:

Thanks. I will check that out. Like a fool, I didn’t even search for this in the Rhino Common libraries…

1 Like