How to run a grasshopper definition from rhino compute with hops?

Hi all

As @AndyPayne wrote in a topic the definition of Inputs and outputs in grasshoper for rhinocompute with RH_IN: and RH_OUT: is the old way to interact betweend grasshopper and rhinocompute. @AndyPayne you suggest to use Hops instead. But how can we run a grasshopper definition in rhinocompute with hops?

Right now we use GrasshopperCompute.EvaluateDefinition(grasshopperFilePath, _inputDataTreeArray[i]);

Second question, is it possible that some plugins in Rhino are not compatible with rhinocompute? Is there a workaraound to run external plugins in grasshopper with rhinocompute? For example we get the following error using the plugin unifyUVs (it is saved as a gha file in the grasshopper libraries)

Error: CG [09:57:12 ERR] An exception occurred while processing request
System.NullReferenceException: Object reference not set to an instance of an object.
at UnifyUVs.UnifyUVsComponent.SolveInstance(IGH_DataAccess DA)
at Grasshopper.Kernel.GH_Component.Solution_Compute_MixedAccess(GH_StructureIterator it)

Thank you for your help
Silvan

We have several guides that discuss what Hops is and how it works. I would probably start though by looking through the Getting Started section of this guide.
Most plugins are compatible with Rhino.Compute. The main caveat that can sometimes cause issues in plugins is if they have some sort of special UI which requires some user interaction. This obviously fails on Rhino.Compute since it’s running in a headless mode and there is no UI. But, I can’t exactly tell why this particular plugin might be causing issues without really looking closer at the Grasshopper definition.

Dear Andy
Thank you very much for your help. I’ve checked all the Hops related guides and understand it in the context of grasshopper. It’s definitely a very good tool to simplify and speed up grasshopper definitions!

What I still do not understand, how I could call a grasshopper definiton from rhino.compute using Hops. I do not want to open a grasshopper definition to run via hops another grasshopper definition As I understand it is still necessary to call a grasshopper definition from rhino.compute with your named “old style” you named RH_IN: and RH_OUT: and GrasshopperCompute.EvaluateDefinition(grasshopperFilePath, _inputDataTreeArray[i]);
Is that correct?

For the second question, why not all plugins in grasshoper run in rhino.compute, I’ve uploaded a file that I can not run. What ist the best workaround to get it run via rhino.compute? I think in my large grasshopper definition are some more plugins used, that may use special UI.
What would you recommend to run such grashooper definitions with non-campatible plugins in rino.compute?
Plugin_not_running_rhinocompute.gh (12.7 KB)

Thank you very much. I appreciate the help in gerneral on this forum.
Silvan

Hops is merely a “client” which communicates with a backend “server” (ie. rhino.compute). So, hops was created as a simple way to be able to solve grasshopper definitions remotely via rhino.compute…but anything that can send/receive HTTP requests can be turned into a client that can communicate with rhino.compute. We have three libraries that we’ve created to help developers make their own clients depending on their software language preference. We have C#, Javascript, and Python libraries. We also provide a number of samples that you can review which shows different ways to use these libraries with rhino.compute. So, hops would be one way that you can send a grasshopper definition to be solved via rhino.compute… but you are free to develop your own solution depending on your needs. Does that make sense?

As for the second question… I thought I explained why some plugins might not work in rhino.compute. So, short of having the 3rd party developer update their plugins, it’s possible that not all components will be able to be used. That said, I did look at the definition that you posted and it looks like it’s using 2 plugins (Minimum Bounding Box and Unify UVs). I downloaded both from food4Rhino, but I still get an error message saying that it can’t find the plugin for Unify UVs. I downloaded version 2.0 of that plugin. Is that what you’re using? Can you send me a link to the plugin download page so I can use the exact plugin your wanting to use?

Dear Andy

Thank you very much for answering my questions.
Indeed, my programming colleague with C# and I with Hops have managed to run simple GH files on RhinoCompute. I also understood from the second question that some 3rd party plugins are not compatible with RhinoCompute. - Probably mainly because of the headless mode in RhinoCompute.

For the plugin Minimum Bounding Boy we have found a version on GitHub that runs on Rhino Compute.

We are now facing completely different problems. We cannot run the attached simple GH_File on Rhino Compute. The error message “Missing Definiton Objects” appears.

However, if we copy all components on the canvas into a new GH file, it works again in RhinoCompute. Do you know what the problem is? -We have tested it on two different computers. With C# as well as with Hops. We keep getting these and similar error messages and debugging becomes a torture.

In C# it is still possible to output partial results, even if errors appear. Is this also possible with hops?
In C# e.g.:

if (output == null)
 {
 ctx.Response.StatusCode = 500;
}
else
{
 ctx.Response.StatusCode = 200;

Is there an overview of do’s and don’ts when using Grasshopper in Rhino Compute and a debugging guide for non-programmers?

Thank you very much
Silvan
PS: The file contains a Pufferfish component Bounding Rectangle. All the other components should be native.

GH-file_sometimesnotrunning_Hops_V1.gh (78.9 KB)

Did you install any 3rd party plugins on the computer that is running rhino.compute? For example, if your running rhino.compute on a VM, you also need to install the plugins on that machine as f you want to solve definitions using components from that plugin… otherwise you’ll get an error message saying that it is missing definition objects (ie components).

Hi Andy

Yes, I am using some 3rd party plugins and have them installed on the computer I am using. I am testing RhinoCompute locally.
Sometimes it works and sometimes it doesn’t and we don’t understand why.

Thank you very much for your help

All the best
Silvan

Hi Andy

I hope I could anwer your question. It should not be a problem because of missing 3rd party plugins.
Can you please help me: https://discourse.mcneel.com/t/how-to-run-a-grasshopper-definition-from-rhino-compute-with-hops/199981/5?u=silvan_bruhin

Many thanks and all the best
Silvan

Can you try sending a GET request to your server and hitting the endpoint /plugins/gh/installed? This should return a list of all plugins installed on your server? This will let you verify if indeed the plugin you’re using is actually installed on your server? The “Missing Definition Objects” message means that it can not find a component in the definition that you’re sending over to the server… so there must be some component in your definition that isn’t installed on the server.

Hi Andy

When an uninstalled Plugin is causing the problem. Why the Gh-File sometimes run? Below I’ve copy pasted you all Plugins I have installed.

Installed Plugins on local host:

{“Bifocals”:“0.5.0.0”,“BitmapComponent”:“1.26.0”,“Bowerbird2”:“2.8.0.0”,“BZ Pattern +”:“0.1”,“Clipper2”:“1.0.0.0”,“ClipperComponents”:“0.3.3.0”,“DendroGH”:“0.9.1-alpha”,“Droid”:“2.0.7701.24821”,“Fattener”:“0.0.0.1”,“Flexibility”:“22.9.2”,“GHPT”:“1.0.0.0”,“GrasshopperHyperGooComponents”:“1.26.0”,“Hops”:“0.16.23”,“Human UI”:“0.8.8”,“Isopod”:“1.0.4”,“IWK Sammelmappe”:“1.0.0.0”,“jSwan”:“1.2.1”,“Kangaroo2 Components”:“2.5.3”,“LunchBox”:“2024.2.9.0”,“LunchBoxML”:“2024.2.9.0”,“MeshCageMorph2”:“1.0.0.0”,“MeshEdit Components”:“2.0.0.0”,“MeshMachine”:“0.2.0”,“MetaHopper”:“1.2.4”,“MinimumBoundingBox”:“1.2.0.0”,“MiscToolbox”:“0.0.14”,“Nautilus”:“1.9.9.8”,“NGon_RH8”:“1.0.0.0”,“Pancake”:“2.8.1.0”,“Parakeet”:“1.1.0”,“Pufferfish”:“3.0.0.0”,“RhinoCodePluginGH”:“8.9.24194.18121”,“SdGhPdfComponents”:“1.26.0”,“Shortest Walk in Gh”:“1.5.1.0”,“Silkworm”:“0.1.1.26851”,“Squid (ShapeDiver Edition)”:“1.26.0”,“Squisher”:“1.0.0.0”,“Synapse”:“0.5.0.0”,“UnifyUVs”:“1.0.0.0”,“VoxelTools”:“1.0.5”,“Weaverbird”:“0.9.0.1”,“Wombat”:“1.1.0.0”}

Used Components on canvas (getting from metahopper document info):

ContextualComponents.ContextBakeComponent

Pufferfish.Components.Components_Curve._5_Curve.BoundingRectangle

SurfaceComponents.AnalysisComponents.Component_AreaProperties

VectorComponents.PlaneComponents.Component_PlaneOrigin

VectorComponents.PlaneComponents.Component_XYPlane

VectorComponents.PointComponents.Component_DeconstructPoint

VectorComponents.PointComponents.Component_ConstructPoint

LinearXForms.Component_Project

Thanks and all the best
Silvan

Are you sending your definition to a local rhino.compute server? Or a remote server (ie. a virtual machine)? If it’s a remote machine, then the plugins need to be installed on that machine.

Hi Andy
I use Rhino Compute local.
So far we also facing strange behavior with some files just not running sometimes. When we copy paste all components on the canvas into a new file, the gh-file is executed.

In C# it is still possible to output partial results, even if errors appear. Is this also possible with hops?

Thank you for your further help.

Hey @andyopayne im currenlty researching how i can use hops to speed up simulation workflows in parallel and pipeline.

is there a huge margin inbetween hosting rhino.compute locally versus remote ?
also is it possible to have in case being remote - multiple remotes running and hops orchestrates parts of the script to each to run in parallel over more then one mashine ?

maybe you have some information about it!

best,

Timon