Running custom Rhino Plug-In with Rhino compute

Hey guys,

I just came across the awesome possibilties of Rhino Compute and I was wondering if it would be also possible to run custom Rhino Plug-Ins with Rhino Compute?

The stuff I looked at (the AEC tech session by Luis Fraguada and Will Pearson) dealt mostly with running Grasshopper definitions on the web server.

In my case the Plug-In is written in C# and basically allows the user to select some geometry, do some calculation and then gives feedback via a WinForms dashboard (if that even matters).

Cheers,
Niklas

Hi @haschke.niklas,

Yes it is possible to have compute use functions exposed in your plug-in.

First, create a class that has one more static methods you’d like to expose.

Then, registe the class so that it can participate as a compute endpoint.

For example:

namespace MyRhino
{
  public class MyRhinoPlugin : Rhino.PlugIns.PlugIn
  {
    public MyRhinoPlugin()
    {
      Instance = this;

      // Register Rhino.Compute endpoint
      Rhino.Runtime.HostUtils.RegisterComputeEndpoint("Rhino/Geometry/MyGeometry", typeof(MyGeometry));
    }

    public static MyRhinoPlugin Instance { get; private set; }
  }

  /// <summary>
  /// Endpoints methods for Rhino.Compute.
  /// </summary>
  public static class MyGeometry
  {
    /// <summary>
    /// Sample method to add two doubles.
    /// </summary>
    private static double AddDoubles(double a, double b)
    {
      return a + b;
    }
  }
}

Hope this helps.

– Dale

1 Like

Hey Dale, thank you very much for your answer and sorry for coming back to it again.

So, I have to do this for every class that I created in my PlugIn?
And does that also works for functiosn like SelectObject (am I able to upload and select geometry in the browser)?

No, just classes who have methods you want to create endpoints for, so they are callable from Compute.

Well no. Compute is not Rhino running in a browser.

– Dale