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

2 Likes

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

1 Like

Hii Dale,

I am little confused here. We are making class static which is MyGeometry in this case and we have made an endpoint for that class name. My question is the AddDoubles is the function which is doing actual work. how are we calling that function and also if there are multiple methods inside this class how are we going to call them individually ?

Thanks,
Shivam

Hi @Shivam_Mahajan,

Does this help?

– Dale

1 Like

Hii Dale,

May be I am missing something but I am still confused, if we see a ComputePlugin example here ComputePlugin

They have written 2 functions inside one static class convert3dmtodwg(…) and convert3dmtopdf (…) and for these 2 functions they have created 2 different endpoints. I just wanted to know where and how they have define these 2 endpoints ?

Thanks ,
Shivam

1 Like

Hi @Shivam_Mahajan,

I am not familiar with the sample you’ve referenced.

I was referring to this:

MyRhino.zip (23.8 KB)

Build the attached plug-in. Then launch Rhino and load it. Now close Rhino.

Now build and launch Rhino.Compute locally.

When the server is up and running, hit the sdk page from your web browser.

http://localhost:8081/sdk

Scroll the list to the bottom - you’ll see the plug-in provided endpoints.

image

– Dale

1 Like

Hii Dale ,

Thanks for replying, I am able to see the endpoints but I was wondering how can I test those on postman. I have posted the same on forum also here is the link

Super thanks for reply,
Shivam