Reverse PolyCurve specific segments


I have some polycurve, created by joined curves. Curves can be arcs, lines or nurbs. Nurbs are problem here - they are created by points, and some of them has reverse point creation then other polycurve segments. is there some package/function to get all curves from polycurve, check direction, and reverse nurbs curves which are in wrong direction?


I had a similar issue a while ago. I had 2 polycurves which I needed to be in the same directions as well as starting from the same (well closest) points.

In the end I had to revert to a python node to accomplish this. RFO: Sort 2 Selections of Curves to Match closest


I think i have better solution, to cycle through curves and check distance between end point of previous and start point of next segment. If that distance is zero, pass, else reverse next segment. Of course, first segment of polycurve must be in right direction. I just need to develop it now :slight_smile:


That’s very much what I did in mine. Only thing is (for mine) I couldn’t work out how to do that using only nodes, had to do that using Python. And I didn’t use 0 distance, just got the closest curve which has its start/end point closest to the other’s end point (if it was the end, then I reverse the curve).

As you explain it it just “might” be possible using a LoopWhile idea. Though going with pure nodes I think the operation will be an O(N^2) algorithm, as for each curve you’d have to check through all other curves - even if they’re already sorted in their proper directions. That’s where the python code is a bit more optimal, i.e. I remove the curves already taken account of, so the next test has less to sort through until the last one only has one curve to check (i.e. an O(N log N) algorithm). If you can work out how to do that using only nodes, I’d be very interested.


Actually, I don’t use nodes except I need to. Every single loop goes through Python, and a lot of no-loop code. It’s 100 times faster


Hi guys,

My understanding is that once you join up the curves into a PC with “PolyCurve.ByJoinedCurves” and then extract them back with “PolyCurve.Curves”, they should already be orientated consistently and shouldn’t need any further adjustment. I drew a few discontinuous curves and joined them up to test this out.

The default curve orientation:



The extracted “sorted” curves:



Didn’t try that, I reversed them through Python, but this is very interesting solution