Rhino + Grasshopper as parametric geometry server


I’m wondering if I can use Rhino + Grasshopper (via command line or scripting) as backend for a web application. The idea is to have the different GH parameters in the web, play with them and generate a 3D preview to see if the model is how the user wants.

This will involve a Windows server with a REST application which will start the workflow in the server itself. The steps would be:

  1. Invoke the program opening
  2. Retrieve parameters
  3. Open GH
  4. Set the GH script parameters with the given parameters value
  5. Generate / Export somehow the generated model so it can be viewed on the web application.

I was reading a little, and the things I don’t know how to do is to open GH from Rhino and set te parameters. Do you think it can be done?

Thanks in advance!

This topic shows you how to load and manipulate Grasshopper from code to open files in GH

Then you need to make sure that the GH file you open can give a result in an unsupervised manner. The easiest I guess is that your web service writes everything to a file, which is then read back in by Grasshopper.

The nicest would be if you could write the result to WebGL format, which can be shown by any modern browser.

1 Like

That is EXACTLY what i was looking for! Thanks!

The file was mi initial idea, i want something more dynamic to don’t depend on the server’s disks. That will imply waiting a random time to be sure the I/O operation finished or listening for changes in one directory. I’ll be looking if it is possible to open Rhino with parameters (like the file path when you double click a Rhino file in Windows) and then pass the parameters to GH. It’s more complicated, but theoretically, it should work better.

For the result, i was thinking exporting the generated geometry as STL to a S3 bucket and return the URL from the backend so the frontend can retrieve it, but today i found this: http://va3c.github.io/ , which seems like a better option.

What do you think?

Thanks again!