Split Curve by Degree

Hello, first post here, thank you for all the great content in here!

If I create a single curve by joining a line (A), an arc (B) and a 3rd degree curve © together. (their start and end points match).

How can I split the single curve apart in code? Ideally I’d like to get a list containing the line, the arc and then the 3rd degree curve(s) - ideally as beziers [hope I am not asking too much!].

Things I have tried:

  • Convert - this will produce lines and arcs but will approximate the curve with arcs :-/

  • ConvertToBeziers – this will give a list of beziers broken in mostly the right places. I could do find the lines with a test for colinarity of control points. Then try and write a test for whether the Bezier is an arc [not sure how!] followed by a merging of consecutive arcs with the same radius.

  • curve.ToNurbsCurve().
    .MakeNonRational() // to remove the weights

I feel like this should do the same as ConvertToBeziers but it doesn’t – the degree 2 sections (arcs) are distorted in this process – I think in the MakeNonRational call?

  • The code mention in this thread ConvertToBeziers however this resamples the curve and adds 10x the number of points.

Maybe you know of a better approach?

Hi David -
Just trying to clarify this so that, perhaps, it gets easier for a developer to answer…

When Rhino joins these objects, it creates a “polycurve”. When you explode that, you will get the individual curves back.
It won’t automatically chop the polycurve at places where curves have different degrees, though.

I guess that’s a somewhat different question - or the next step? With the methods mentioned on that page, you should be able to check each segment and then decide to run some code on that segment.

1 Like

Thank you, Adding the curve to a PolyCurve then calling Polycurve.RemoveNesting() and then Explode Is producing the results I am looking for
Thank you :smile: