Grasshopper addons in Rhino Compute

I’m running Rhino Compute locally (in a docker container on Windows). My goal is to run Grasshopper scripts and I have got that to work.

Now I’m trying to add Grasshopper addons, so I can use them in the Grasshopper scripts.

If I try to run a script that uses the Anemone addon I get the following error;

System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at Grasshopper.Kernel.GH_Document.InstallMissingObjects(GH_IReader reader, ObjectDeserialisationInfo[] info)
   at Grasshopper.Kernel.GH_Document.ReadObjectList(GH_IReader reader, String collection, List`1 plugins)
   at Grasshopper.Kernel.GH_Document.Read(GH_IReader reader)
   at GH_IO.Serialization.GH_Archive.ExtractObject(GH_ISerializable target, String targetName)
   at compute.geometry.ResthopperEndpointsModule.Grasshopper(NancyContext ctx) in C:\src\compute.geometry\ResthopperEndpoints.cs:line 87
   at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context)

I guess this is Grasshopper trying to open a dialog offering to download the Anemone addon. Fine.

So I tried to fix that by adding the Anemone addon file, i.e. anemone.gha, to the following folders:

  • “C:/Users/ContainerAdministrator/AppData/Roaming/Grasshopper/6/Libraries/”
  • “C:/Users/ContainerAdministrator/AppData/Roaming/Grasshopper/Libraries/”

But I still get the same error.

Does anyone know if that should work, or if there are any other things to do to make it work?


1 Like

If you run Grasshopper in normal UI mode for that install, do you get a modal dialog?

Are you using the latest V7 WIP? I recently made the InstallMissingObjects function throw a descriptive exception instead of showing a dialog when running headless.

I’m running the docker setup so I have never run it with a UI. However, I have installed the latest WIP on another Windows computer and there I do get the popup if the addon is missing. But no popup if the addon is present.

As for the version I’m using the version in the Dockerfile:

ADD rhino_installer.exe

That was a bit old. So I just now tried the newest one and no crash! However, no output either. Not sure if it works or not, but at least I can take a step forward and investigate that.

I’ll report back my findings. Thanks!

You can add a callback to Rhino.Runtime.HostUtils.OnExceptionReport to get information about errors that may have occurred

I added a listener to the callback, but it does not seem to be called.

Rhino.Runtime.HostUtils.OnExceptionReport += (source, ex) => {
  Log.Error(ex, source, "An exception occured while processing request");

Is there anything else to be doe for a Grasshopper addon to be found?

Is there a way to force detection? Or list what is available?

I tried moving the Grasshopper addon to the Grasshopper components folder:

"C:/Program Files/Rhino 7 WIP/Plug-ins/Grasshopper/Components/"

But then I got this error at startup:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
   at System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp)
   at System.Windows.Forms.MessageBox.Show(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon)
   at Grasshopper.Instances.get_ComponentServer()
   at Grasshopper.Instances.RunHeadless()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at compute.geometry.Bootstrapper.ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
   at Nancy.Bootstrapper.NancyBootstrapperBase`1.Initialise()
   at Nancy.Hosting.Self.NancyHost..ctor(INancyBootstrapper bootstrapper, HostConfiguration configuration, Uri[] baseUris)
   at compute.geometry.NancySelfHost.Start(Int32 http_port)
   at compute.geometry.Program.<>c__DisplayClass4_0.<Main>b__3(NancySelfHost tc)
   at Topshelf.ServiceConfiguratorExtensions.<>c__DisplayClass2_0`1.<WhenStarted>b__0(T service, HostControl control)
   at Topshelf.Builders.DelegateServiceBuilder`1.DelegateServiceHandle.Start(HostControl hostControl)
   at Topshelf.Hosts.ConsoleRunHost.Run()

After some more testing of GH addons today we have found the following:

  • Weaverbird (installed with yak) works
  • MeshEdit (installed by adding .gha and .dlls) works

Still do not know why Anemone has problems. Is it due to opening a dialog? Or is it not properly registrered? Any ideas are welcome.

1 Like

@MateuszZwierzycki may have a better idea than me, but I suspect we will run into this for several 3rd party components that were designed before compute existed. I will need to install anemone and test here to be able to give any feedback.