Skip to content

Anatomy of a Rhino.Inside Enabled Project

Luis E. Fraguada edited this page Oct 11, 2019 · 3 revisions

There are three main parts of a Rhino.Inside enabled Project:

1. Assembly References

The project should reference the necessary Rhino related assemblies which could include:

  • RhinoCommon.dll - Rhino's cross-platform .NET plugin SDK. (Guide | Reference)
  • Grasshopper.dll - Grasshopper is a .NET (RhinoCommon) plugin for Rhino for Visual Programming. The SDK allows you to program components, react to events, and more. (Guide | Reference)
  • RhinoWindows.dll - This dll gives you access to a Rhino Viewport Control.

NOTE: These assemblies are available with the default Rhino installation or via the Rhino.Inside NuGet package: https://www.nuget.org/packages/Rhino.Inside/.

2. Assembly Resolving

In most cases, you will build Rhino.Inside enabled applications on a computer which has Rhino installed. The host application needs to know where the assemblies have been installed on the computer. You can set up an Assembly Resolver, but we have included assembly resolver code in the Rhino.Inside NuGet package. To use this, you can run this code when your application initializes:

RhinoInside.Resolver.Initialize();

3. Write Code

Your host application should create a new RhinoCore object.

try
{
  using (new Rhino.Runtime.InProcess.RhinoCore())
  {
    // Code to call into RhinoCommon, Grasshopper, etc
  }
} 
catch (System.Exception ex)
{
  // Error handling code.
}

Wrapping this in a using block ensures that the RhinoCore object is properly disposed. Alternatively, you can handle the disposing of the RhinoCore object:

// ... 
var rhinoCore = new Rhino.Runtime.InProcess.RhinoCore();
// ... 
// Your awesome application code
// ...
// Handle disposing the RhinoCore object 
rhinoCore.Dispose();
rhinoCore = null;