Clarity on creating PolyCurves from Lines and Arcs in Rhino Common

I’m looking for some advice on how to become a better user of the Rhino API.

I have several curves that are collections of lines and arcs (can’t be too uncommon) and I would like to preserve the internal lines and arcs as well as some of the benefits of PolyCurves vs. Nurbs Curves, for example being able to split/explode cleanly. What is the best/most efficient way to directly assemble/force PolyCurves in Rhino Common?

I imagine something like the following should be possible:
new_polycurve = Rhino.Geometry.PolyCurve([arc1, arc2, line1], tolerance)

but of course that doesn’t work :frowning:

The API doc on PolyCurve suggests Curve.JoinCurve as a way to accomplish the above, however I cannot use JoinCurve with arcs and line segments… I feel like I must be missing something that is presumably obvious to others.

I have hitherto found it easiest to just cast everything into Nurbs curves prior to joining and keep a copy of the underlying arc or line objects for reference as needed. This is a workaround I would like to stop using. It can become a particular issue when I want to explode a curve later down the line and often end up with several arc segments where I should have a single arc segment (then I get to write some very unnecessary feeling logic).

Thanks.

You can use JoinCurves with LineCurve and ArcCurve objects…

2 Likes

Thank You!

Dear Rhino API developers: I wish there was a ToArcCurve() method similar to the ToNurbsCurve() method, as I completely missed that you had to construct these objects in order to avoid the nurbs pipeline.

You could use the Curve.TryGetArc method.

1 Like

line_crv=Rhino.Geometry.LineCurve(line)
arc_crv=Rhino.Geometry.ArcCurve(arc)

I guess these are just some of the things you figure out after having read the API doc for hours and hours

1 Like

Thank you, I figured it out from your earlier answer but this is a great addition for anyone else who is as confused as I was.

I wish the API naturally pointed the reader in the direction of subtleties like this. Of course the most favorable option would be for Arcs, Circles, Lines, etc to just be automatically upgraded to curve objects when you try to use them with curves, but I suppose someone with more knowledge than I do about the API has already considered that option and the various roadblocks that make it impractical.