Grasshopper within compute.rhino3d

Hello, @dekanifisher !
It’s not only possible, but there is already a prototype! Have you heard of Resthopper? It was a project at the Thornton Tomasetti AEC Tech hackathon that McNeel kindly incorporated into their compute.rhino3d repo. @will just finished updating the public server at compute.rhino3d.com to reflect the latest changes. The route that you are looking for is compute.rhino3d.com/grasshopper. It accepts a POST request with three fields:

{
    "algo" : "Your bit-64 encoded string containing entire GHX file goes here",
    "pointer": "If algo is null, an optional public url to your GHX goes here",
    "values": [ A list of Resthopper data trees which serves as your input goes here]
}

So, essentially, you are passing your entire GHX file (either as a string in the POST body or a public URL) and a list of Resthopper data trees that mimicks Grasshopper data tree structure and contains serialized RhinoCommon geometry.

Here’s what the route looks like:

And this is the I\O necessary to talk to it:

Finally, there is a formatting standard that defines how the Grasshopper file has to be organized. Each Resthopper Tree has a ParamName field. This lets the compute server know which param in the definition each data tree from the “values” section belongs to. In the definition itself all you have to do is create a group around each input param and call it “RH_IN:<type_enum>:<unique_name>”. For instance, consider this definition:

Your input schema will include two trees: one named “RH_IN:108:Crv1” and another one named “RH_IN:108:Crv2”. The 108 enum simply lets the server know that you are passing a curve. The complete list of type enums is available here:

You will then receive back the same schema, however the “algo” and the “pointer” fields would be empty, and the values section will contain one DataTree of points with ParamName set to “RH_OUT:102:OutPt”. You can have any number of inputs / outputs as long as the names remain unique.

Let me know if you have any questions!
Hope this helps,
Best!
Sergey

8 Likes