Running Rhino/GH as a Service

I wonder if this is possible. I have a GH “definition” that I would like to launch from a bat file which would run rhino as a service.

The idea is to be able to run Rhino/GH from a external app, but being “hidden” for the user.

After some googling, I found that there are applications that are able to lauch any app as a service, but this is not an option for me since it would complicate things for my ““plugin”” users.

The ideal solution would be to launch Rhino with some “magic” option from my bat file. Am I dreaming?

Any idea would be much appreciated

thanks

If I could start from scratch, I would start implementing everything using only rhinocompute, but right now its not an option for me, I guess…

I’m using Shapediver for similar case.

No, you are not dreaming. Start kicking the ball by invoking a “main” GH definition as described below.

Given the file “main.ps1” placed in the sub-folder “run” and the file having something like the following content (I keep the comments I had in my file, for your information);

# https://ss64.com/ps/set-executionpolicy.html
# Set-ExecutionPolicy -executionPolicy Unrestricted
# Call this script like so:
# powershell -executionpolicy unrestricted .\main.ps1

[System.Diagnostics.Process]::Start("Rhino.exe", "/nosplash /Grasshopper run\\Main.ghx").WaitForExit()
Write-Host "Rhino.exe has terminated."

And off you go.

I no longer remember if this invocation is hidden or not (it’s from 2018), but you’ll find out.

// Rolf

I know many people here know about these, but there are so many emerging technologies here it is worth reviewing a few.

Rhino 7 additions that help support batch commands:

  1. Compute - Rhino/GH as a service
  2. Rhino3DM Client Libraries to pass Geometry as JSON without the need for Rhino ( rhino3dm.js).
  3. GrasshopperPlayer in Rhino 7 (Compute or Desktop)
  4. New context sensitive input components for development and deployment of Grasshopper definitions on both desktop cloud and other platforms.
  5. Placeholder capability of Grasshopper components that allow definitions to edited across multiple contexts.

Online Cloud platforms:

  1. Shapediver allows some of this.
  2. Swarm from TT Core Studio
  3. Hypar
  4. I know there are more…

And of course on the desktop, you can use your own application framework to can into Rhino.Inside and Grasshopper as a DLL and run simple batch commands from there.

1 Like

Wow, didn’t know about that one! That’s an absolutely brilliant idea!

So if I understand it correctly, a “GHPlayer command” could then also be activated via Rhino.Compute, or via CommandLine from a bat-file?

// Rolf

Yes. Compute or Command line. Inputs can be customized to be interactive or automatic in different contexts. Of course the devil is in the details and this is a developing set of features, so any feedback or results you are getting we would be happy to hear about.

It is also important to know that Compute can also take a series of “commands” and then return the results. This improves performance by reducing the amount of data sent back and forth.

1 Like

moving to this thread Rhino.Compute -- Type conflicts

Blockquote
[System.Diagnostics.Process]::Start(“Rhino.exe”, “/nosplash /Grasshopper run\Main.ghx”).WaitForExit()
Write-Host “Rhino.exe has terminated.”

Rhil, this is to launch Rhino from shell, right? But this is launching also the UI. What I was looking is to Rhino running as a “daemon”, without UI. Maybe “running as a service” its not the correct expresion?

Yes, it launches Rhino&GH UI.

I think RhinoCompute is what you are looking for. (That which I’m experimenting with right now).

// Rolf

I think RhinoCompute is what you are looking for. (That which I’m experimenting with right now).

the problem with rhinocompute is that is exposing “just” the geometry classes. We have implemented lot of doc related classes and events…

it could work in other completely different implementation of the project

Basically what I want is to launch Rhino and the grasshopper from illustrator to execute our ““not-a-plugin”” to make stuff in Rhino but with interaction from Illustrator. It’s quite a mess…

Rhino,Inside can run kind of like a daemon, but it is different. Because Rhino.Inside will load as a DLL inside any other program, You can create a simple application that acts like the shell, but is loading Rhino.Inside. In fact if that simple application can take commandline args, you can just add a series of commands to your shell.

Here is some sample code to do this: https://github.com/mcneel/rhino.inside/tree/master/ConsoleApps

What shell are you using specifically? What language do you program in?

Lots of ways to do this. Just really depends on your goal.

moving to this thread: Rhino.Compute -- Type conflicts

// Rolf

I’m using windows dos comand line and Rhinocommon is in IronPython and UI with ETO

Basically what I want is to launch Rhino and the grasshopper from illustrator to execute our ““not-a-plugin”” to make stuff in Rhino but with interaction from Illustrator. It’s quite a mess…

Will give a look to RhinoInside. It was out in my mental schema, since I related this technology with .net framework (CC illustrator its not…)

Perhaps you want to look at this thread: Rhino inside Python

It uses CPython, but I expect IronPython is similar.

For a desktop solution, Rhino.Inside is the way to go.

For cloud solutions or where Rhino does not exist on the client, then Compute will work, but the performance can be quite different.

1 Like

Thanks scott, will give a look to all this. I will be back with more problems once studied all this a little bit. Thanks!

CC Illustrator is a very different beast and looks to be quite a challenge. You can see an experiment on Rhino.Inside with Illustrator : https://github.com/mcneel/rhino.inside/tree/master/Adobe/Illustrator

There are still many questions about how to interact with illustrator once inside.