A RhinoCommon method for interactively drawing a NURBS Curve

In RhinoCommon Rhino.Input.RhinoGet.GetPolyline(out pline) throws Rhino into drawing mode, lets the user set points for the polyline, and draws the live preview of the polyline in the process. However, there doesn’t seem to be anything for interactively drawing a NURBS Curve. I could of course just collect points and then use them to build a curve myself, but then I’d have to deal with interactively redrawing the curve preview. Any suggestions?

Rhino has built-in functionality, the Curve command. This can be scripted from code, using RunScript(…). This is probably easiest to do.

If you really want to interactively preview-draw a curve completely from code, you should look into display conduits.

Thanks @menno! I considered RunScript() as well, however, I’m not sure how to then get the ObjRef for the created curve (or the Curve itself). And I’ve worked with display conduits before - it’s a pretty involved undertaking haha

Use the GetPoint class to get a series of points.This class has a virtual function called OnDynamicDraw (or DyanmicDraw even) where you can draw your temporary curve.

2 Likes

Awesome! Thanks @stevebaer !

This is essentially how GetPolyline works. We just happened to wrap it up into an easy to use function.