Extending Compute with Custom Endpoints
Windows only

By default Compute exposes a long list of endpoints, designed to expose functionality in RhinoCommon as well as enabling Grasshopper definitions and Python scripts to be solved. It’s also possible to extend Compute with your own custom endpoints by registering functions in a Rhino plug-in. Compute handles the serialization.

First define a static class in your plug-in and add the new function as a static method (you can add more than one!).

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;

Then, in the OnLoad method of the plug-in’s PlugIn class, register the function. This code is called once when the plug-in is loaded by Rhino.

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, both locally for testing and on any servers where Compute runs.

Once this is complete, you should be able to open the /sdk endpoint in a browser and see the new functions listed at the bottom of the page.

Check out the ComputePlugIn sample in the Rhino Developer Samples repository.