Extending RhinoCompute Server with plugins

There is a function in the V7 RhinoCommon named

Rhino.Runtime.HostUtils.RegisterComputeEndPoint(string, Type)

The idea is that you would define a static class in your plugin and then register that class with compute when the plugin is first loaded. For example

static class MyCustomComputeFunctions
{
  public static double Add(double, x, double y, double z) { return x+y+z; }

  public static double AdjustedArea(Curve curve, double adjuster)
  {
    var amp = Rhino.Geometry.AreaMassProperties.Compute(curve);
    return amp.Area * adjuster;
  }
}

In your plugin’s OnLoad function you would add

protected override LoadReturnCode OnLoad(ref string errorMessage)
{
  Rhino.Runtime.HostUtils.RegisterComputeEndPoint("Rhino.CustomEndPoint", typeof(MyCustomComputeFunctions));

  return base.OnLoad(ref errorMessage);
}

You will need to install your plug-in in Rhino for your custom compute server.

Once this is complete, you should be able to go to your custom compute /sdk endpoint and see the new functions listed at the bottom of the page.

5 Likes