Deprecated Rhino3dmIO?

Hi there!

I am writing a unit testing suite for a project that uses RhinoCommon (because it will live inside a Rhino app). For the tests, I started using FileIO to load some test geometry from a file, ran into errors, and @stevebaer 's post pointed me to the Rhino3dmIO project, which is working great so far.

However, NuGet says the project is deprecated? And also, it worries me that the tests might be using a different RhinoCommon version that the one that will be available in the target.

What is the plan for Rhino3dmIO? Is there any replacement for this kind of scenario?

Thanks!

JL

The project is now Rhino3dm. It was mostly a name change to go along with the python and javascript versions of the library.

Thanks a lot @stevebaer ! Now I am running into the problem that the Rhino3dm geometry classes are not compatible with the ones present in the RhinoCommon plugin project… :sob:
Is there any way to marshall between them?

What are you trying to do? I’m confused why you need both Rhino3dm and RhinoCommon in the same project

Let me try :sweat_smile:

  • I am writing a Rhino plugin (Project P), that uses a lot of geometric functionality that has been abstracted to a Core dll (Project C), both of which depend on RhinoCommon. The idea is to write reusable code in Project C that could be used for other plugins, GH components, etc.
  • I am trying to write unit tests for Project C, to verify that the computations are correct. The tests are meant to be ran on Build in pure VS, without firing an instance of a Rhino application to handle them.
  • For the tests, I am trying to load some geometry from sample 3dm files, convert to geometry types (Brep, Curve, etc.) and use those in the tests.
  • If I use RhinoCommon in the unit test project, when I read 3dm files using File3dm I run into this problem, because I am not inside a Rhino application.
  • If I use RhinoCommon to try to load that same geometry from a serialized json file, I run into the same issue when working with CommonObject.
  • If I use Rhino3dm for either of the two options above, loading the 3dm file works great. However, now the problem is that the Rhino3dm Geometry classes in the unit tests are not compatible with their RhinoCommon siblings used in Project C. Therefore, can not use them to test the Project C library.
  • At this point in the project, we cannot change Project P and/or C to depend on Rhino3dm, and I also don’t think that would be good for either, since they are targeting living inside a Rhino runtime…

Sooo, I am kind of stuck here, and not sure how to move forward. Ideally, I would like to be able to load geometry from a file using RhinoCommon headles, or find a way to marshall between a Rhino3dm Brep and a RhinoCommon one for example. But even this last option would probably not work, since a project cannot depend on both RhinoCommon and Rhino3dm at the same time!

Any help would be much appreciated, thanks a lot @stevebaer :nerd_face:

@garciadelcastillo - perhaps this will help.

– Dale

You can edit your project C’s csproj to use different references for different build configurations. This way you can have a Debug and Release configuration that reference RhinoCommon and a new Test configuration that references Rhino3dm. We can help you with these adjustments if you think this would work for you.

@dale thanks for the pointer, this could be really helpful. I will take a look.

@stevebaer that sounds like it could save A LOT of work. Do you have pointers/documentation on how to set this up? Never done this.

Thanks to both! :rhinoceros:

Sad news @dale, still run into the same error that originated this post:

Unable to create instance of class ProjectCUnitTesting.BrepsLoaded. Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DllNotFoundException: Unable to load DLL 'rhcommon_c': The specified module could not be found. (Exception from HRESULT: 0x8007007E).

Looks like I may have to try @stevebaer 's way… :slight_smile:

You can only use RhinoCommon when loaded into the same process as Rhino.exe. This is why you are getting the above error. I’ll see what I can do to help show how to use different references for different build configurations.

I am half-way there with the different references for different build configurations. However, I am not sure this approach is going to work either. When I replace the RhinoCommon dependency of Project C with Rhino3dm, but turns out it’s missing a lot of functionality:

Am I doing something wrong, or Rhino3dm is doesn’t (yet?) contain the full RhinoCommon API?

Hi @garciadelcastillo,

Rhino3dm is not the full RhinoCommon, and never will be. Basically there is stuff in Rhino we are not willing to give away for free.

Rhino3dm is based on openNURBS. And here are some of its limitations.

Hope this helps.

– Dale

I hear you @dale , makes sense.

So then, here is the big question: is there any way I can load/deserialize some form of geometry file using RhinoCommon outside a Rhino process? All these methods gave me the same dll missing errors:

  • Loading a 3dm file with File3dm and converting its to File3dmObjects to geometry types.
  • Loading a json-serialized version of the above and trying to deserialize it with CommonObject.FromJSON().
  • Loading a byte-serialized version of the above and trying to deserialize it with @dale’s BinaryFormatter method.

Any leads would be much appreciated, thank you! :rhinoceros:

You cannot use RhinoCommon outside of Rhino. If you need to read .3dm files outside of Rhino, use Rhino3dm.

– Dale

You probably want to use Rhino.Inside technology for this since you need access to RhinoCommon features which are not available in Rhino3dm. There is a RhinoInside nuget package that you can use.

Here are some samples