Converting the codebase of a plug-in from Rhino.NET to Rhinocommon

We have a plug-in which we are looking at updating for Rhino 6. It has quite a lot of code that uses Rhino.NET, and I understand that this is no longer supported, but should be replaced by Rhinocommon libraries.

I do not have any experience with this, so any pointers to learning materials would be appreciated. Is there a guide on what mapping / replacement of classes and functions is involved in moving from Rhino.NET to RhinoCommon?

I am trying to understand the difference between Geometry in the Rhino.Geometry library and in the Rhino.DocObjects library. Am I right in assuming that the DocObjects contain the geometry and the GUID and that I should be looking to operate with those? Should the RMA object (such as MRhinoCurveObject) typically be replaced by DocObjects?

The kind of questions I am looking to answer are as follows. What are the replacements for the following (or where should I go to look)?:

  • On3dPoint -> Point3d
  • On3dVector -> Vector3d
  • OnLine -> Line (?)
  • OnLineCurve -> ?
  • MRhinoCurveObject -> Rhino.DocObjects.CurveObject or Rhino.Geometry.Curve ?
  • OnObject -> Object(?)
  • RhUtil -> ? (is there a comparison anywhere)
  • RMA.Rhino-> ?
  • RMA.OpenNURBS -> ?

I need to replace the following code (in VB.NET):
a_function(…, ByRef line As OnLine, …)
if line IsNot Nothing …

Can I replace this with:
a_function(…, ByRef line As Line, …)
if line.IsValid …

@dale, is this something you can help with?

1 Like

Hi @dale - it would be great if you could give me some pointers.

Hi @Andrew_Mole,

Sorry, this issue seems to have gotten buried. How is your progress? Is there anything we can help with?

– Dale

Hi Dale, no, we have not made any progress on this. Do you have any available guidance on this, whether general or detailed? I thought that you might have put out some guidance when the switch took place - guidance for developers inside or outside Rhino. I have not been able to find anything, though. Perhaps I (& Google) have been looking in the wrong places.

Hi @Andrew_Mole,

For developing plug-ins for Rhino using RhinoCommon, the place to start is here:

https://developer.rhino3d.com/guides/rhinocommon/

We have a load of developer samples available on our GitHub site.

https://github.com/mcneel/rhino-developer-samples

And you can find API documentation here:

https://developer.rhino3d.com/api/RhinoCommon/html/R_Project_RhinoCommon.htm

If you are looking for “I did this in Rhino_DotNet, how to I do this in RhinoCommon” questions, it might be best we take these one-at-a-time.

– Dale

Thank you for this. I wasn’t aware of the developer samples, but I was aware of the others.

So… regarding specifics, what replaces the following:

  • RMA.Rhino
  • RMA.Rhino.RhUtil
  • RMA.OpenNURBS
  • RhinoApp
  • RhinoCurve
  • RhinoCurve.SetCurve(Line)
  • MRhinoCurveObject (how is this different from RhinoCurve?)
  • MRhinoMeshObject
  • OnMesh (how is this different from
  • MRhinoObjectAttributes
  • OnLineCurve
  • OnObject
  • Point3dArray
  • OnUtil

I hope you don’t mind me asking you a few of these (some of which may not have answers) as I am hoping that whatever you can answer will give me the general idea of how to move forward.

One other thought - do you have a manual for Rhino.NET that I could use to understand the old code (never having programmed with Rhino.NET)?

Hi @Andrew_Mole,

Keep in mind that there is not a one-to-one correspondence between Rhino_DotNet and RhinoCommon. Rhino_DotNet was structured around the Rhino C/C++ SDK. There has been more thought put into RhinoCommon and the organization of the namespaces.

But in general:

Rhino Namespace

There is no equivalent. These static function are implemented as either static or member functions on the appropriate classes.

For the most part, this is the Rhino.Geometry namespace

RhinoApp class

Rhino.DocObjects.CurveObject class

In RhinoCommon, you’d just add the line to the document directly using ObjectTable.AddLine.

Rhino.DocObjects.CurveObject class

Rhino.Geometry.Mesh class

Rhino.DocObjects.ObjectAttributes class

Rhino.Geometry.LineCurve class

Rhino.Runtime.CommonObject class

Most just use a System.Collections.Generic.List object

There is no equivalent.

Well, there is this: https://wiki.mcneel.com/developer/dotnetplugins

And this: RhinoDotNetDocs.zip (19.2 MB)

– Dale

1 Like

It should also be noted that you can still reference both RhinoDotNet and RhinoCommon in a single plugin for Rhino 6. Converting to RhinoCommon doesn’t need to be an “all or nothing” type conversion. Instead, it can transform over time.

@stevebaer

Hi Steve, that sounds very interesting to me. Are you saying that we don’t need to do the conversion to RhinoCommon, but can continue to reference the RhinoDotNet library? We would prefer to make no change…

Dale, thank you for all this. One noobie question… I am trying to replace the following line:

Dim RhinoCurve As New MRhinoCurveObject

I have tried to replace it with:

Dim RhinoCurve As New Rhino.DocObjects.CurveObject

But I find that there is no ‘New’ constructor. What should I use to initialize a CurveObject?

That is a little tricky to answer correctly. We broke some of our SDK with respect to RhinoDotNet in V6 so there is a good chance your plugin won’t load in V6 right now without at least some modifications. That said, if you send me your plugin, I can see if we can change any code to possibly get things working again.

The other route is to start with a new RhinoCommon based plugin and add RhinoDotNet as an assembly reference to that plugin. Once that is done you can create RhinoCommon commands, but use legacy RhinoDotNet code inside of the commands (your existing code).

1 Like

This is not allowed in RhinoCommon. You typically create a curve object just to add it to the document. In that case you would just call doc.Objects.AddCurve(…) passing your curve geometry to the function

1 Like