There are only three components in the ghx file. Two of them are input and output text components and the third is a custom component, which I’ve copied to the GH’s Libraries folder.
When I call the /grasshopper endpoint and I set the input parameter, I get a result back saying that my custom component (Parking Solution Factory from Json) Failed to collect data. Which is weird because the input text component is set properly and I don’t have any warnings regarding that.
When I call the /plugins/gh/installed endpoint I don’t see my custom plugin in the list. So I suspected that my custom component is not loaded at all and the warning I’m getting is misleading, as I see this in the debug window:
As I mentioend, the custom plugin is in the Libraries folder and when I open grasshopper through the UI, the plugin tab shows up and components all work fine.
I’m running rhino.compute locally in Debug mode. So the solutions provided by @AndyPaynehere doesn’t apply.
Additionally, I get the logs as follows which shows the Hosting Environment set to Production! Could that be contributing to the issue?
Hi Hzamani. Is there a specific reason you’re trying to do this via setting JSON and calling specific endpoint directly? Are you able to use Hops? I honestly, think this would be a lot easier if you used Hops and merely pointed the Hops component at your custom .ghx file and it should work automatically without the need to hit specific endpoint and fill out JSON data.
There are a few things that stick out to me about your setup. First, is you’re still using the “older” way to set inputs/outputs… meaning you’re defininig them via RH_IN: and RH_OUT… Those methods should still work, but we recommend using the Context Get and Context Bake components for inputs and outputs as you have more control over how those inputs (in particular) behave. You can read more about those components here.
Also, you said you don’t see your endpoint in the list being returned from /plugins/gh/installed. Well, you’re endpoint wouldn’t show up there, but hopefully the plugin that you created (ie. the .gha file) which exposes whatever endpoint you want to hit would be there. If you’re running things locally then Rhino.Compute should pickup any plugins that are installed for your normal instance of Rhino. Can you confirm that your plugin does indeed work as expected when you run Rhino/Grasshopper?
Also, I would once again reiterate that I think you should be using Hops for this. From your last screenshot, it looks like you’re only running the Compute.Geometry project (which listens in on http://localhost:5000). That used to be the way to do things several years ago, but we’ve since added a top layer application called Rhino.Compute which handles spinning up multiple children processes (the Compute.Geometry process). This is advantageous for several reasons in that if one of your children crashes, then it will automatically spin up a new one, where as if you’re only running a single instance of compute.geometry and it crashes, then there’s no way to rescue that. In addition, with multiple child processes running, you can ultimately have things being computed in parallel (if the definition is configured properly). Please let me know if you have any follow up questions.
What we are looking to achieve is a Revit plugin that delegates geometric calculations to GH by calling our API endpoint and passing a json. Our API server then is responsible for calling Rhino.Compute which is running on the same server, it then should get the results back and return to the Revit plugin as a json. From what I understand Resthopper is designed for this type of workflow, while Hops is for GH users and used for calling a function (another GH) from GH. Is that correct?
The reason is we’re using Resthopper not Hops. Do the Context Get and Bake components work in Resthopper? If so could you please point me to the documentation?
Confirming that my custom plugin located at “C:\Users\hzamani\AppData\Roaming\Grasshopper\Libraries\Toucan\Toucan.gha” does not return from /plugins/gh/installed but for example “C:\Users\hzamani\AppData\Roaming\Grasshopper\Libraries\HumanUI\HumanUI.gha” does show in the list. Also confirming that when I run Rhino and GH as a normal user, my plugin does indeed show up and works perfectly.
What I have tried since posting the question:
Removed my bin directory from GrasshopperDeveloperSettings as I was suspecting the double up (which gets handled by a window asking which gha file I want to load) is stopping GH from loading my plugin while running under Rhino.Compute process.
Removed Newtonsoft.Json.dll from the directory where my gha file is (we are using Newtonsoft.Json and thought that there might be a conflict with other plugins).
Built my plugin using Release settings
Updated my RhinoCommon and Grasshopper references to the latest 8 version. They were previously referencing 7 and Rhino.Compute is running Rhino 8.
Adding a breakpoint at:
static async Task GetInstalledPluginsGrasshopper(HttpContext ctx)
{
var ghPluginInfo = new SortedDictionary<string, string>();
foreach (var obj in Grasshopper.Instances.ComponentServer.ObjectProxies.Where(o => o != null))
{
var asm = Grasshopper.Instances.ComponentServer.FindAssemblyByObject(obj.Guid);
if (asm != null && !string.IsNullOrEmpty(asm.Name) && !asm.IsCoreLibrary && !ghPluginInfo.ContainsKey(asm.Name))
{
var version = (string.IsNullOrEmpty(asm.Version)) ? asm.Assembly.GetName().Version.ToString() : asm.Version;
ghPluginInfo.Add(asm.Name, version);
}
}
ctx.Response.ContentType = "application/json";
await ctx.Response.WriteAsJsonAsync(ghPluginInfo);
}
and I can confirm that Grasshopper.Instances.ComponentServer.ObjectProxies does not contain my custom plugin and for other returned plugins such as HumanUI the path is pointing to my appdata roaming path ie: "C:\Users\hzamani\AppData\Roaming\Grasshopper\Libraries"
Hi @AndyPayne, just following up on this as it’s impeding our development at the moment. Is there any way for us to step into the process where GH plugins are being loaded?
Some additional info on my setup below.
GH developer settings folders:
The Toucan plugin (ours) shows in GH UI as it should but not in the list of plugins endpoint.
Is there any other requirement for a gha file to be considered a plugin? We’re new to GH dev so it’s likely we’re missing something obvious that we can’t find in our investigations.
Thanks to @AndyPayne, we found that we were using an updated version of Serilog in our plugin than what rhino.compute was using. Good old dll hell issue… Reverting to the same version solved the issue. So if your plugin works fine in grasshopper GUI and not working in compute this is an area you can check.