Rhino Inside Revit crashing with Human UI (if window has not been opened)

I’m using the Grasshopper player in Revit, with Human UI. It works great if I open the Grasshopper and Rhino windows, but if I “start” Rhino, then immediately proceed to use the grasshopper player, it crashes Revit.

I think this has to do with the Human UI window trying to bind as a child of the Grasshopper window, but that is just my working theory.

Can anyone opine on possible ways to get around this behavior? An ideal fix would allow the script to run properly, possibly by forcing an initialization of the GH window is needed. Failing that though, something to protect from crashing would also be great. Maybe a custom c# component that would detect if the script was running headlessly and stop execution before the human UI components are triggered? Other brainstorming welcome… will post/ share whatever solution I’m able to develop.

Can you provide us an example I can use to reproduce and file a feature request/bug report? Thanks.

No problem, this script can reproduce the issue.
UI Demo - Does Nothing.gh (65.9 KB)

To replicate the crashing scenario:
Open Revit (any project)
Launch Rhino Inside
Use the Grasshopper player to the run the script
Results in the pop up appearing for an instant, then Revit crashes

To use the script without it crashing:
Open Revit (any project)
Launch Rhino Inside
Click the Grasshopper button to open the GH editor window
Open the script with the script editor or use the Grasshopper player to the run the script
Results in the script working as intended

This works, for posterity… using a C# node to force the Grasshopper window to flash before the HumanUI window tries to go looking for it.

  private void RunScript(object x, object y, ref object A, ref object B)
  {
    dynamic gh = RhinoApp.GetPlugInObject("Grasshopper");

    if (!gh.IsEditorLoaded()){
      gh.ShowEditor();
      gh.HideEditor();
      A = "Grasshopper editor was not loaded but it is now";
      B = true;
    }

    else{
      A = "Grasshopper editor loaded the whole time.";
      B = true;
    }
  }

Thanks for the update. I’ve passed on your sample to devs and have been waiting to hear back.

Thanks @Japhy much appreciated!

@andheum I submitted a pull request to add this trick to “Launch Window Component”, if that is alright.

Hi @Matthew_Breau1,

There is a fix for this problem that will be available on v1.9.

You can test it now updating your RiR copy from the Daily build channel.

1 Like

Thanks @kike and @Japhy, I updated to the daily build and can confirm the Grasshopper Player is no longer crashing in this edge case.

However, there’s a new behavior which is a little “off”. Running the Grasshopper player causes the Human UI window to open, but as soon as the Human UI window loses focus, the Human UI window closes. I tested a few times, and even something like getting a Teams message can pull focus from the window, causing it to close out. I don’t think this happened previously, not sure if there is a way to detect if child windows exist and keep Grasshopper definition running in the background?

@kike and @Japhy, would it be helpful to open this issue on a new thread?

If you have any ideas on how HumanUI could signal to the Grasshopper player that it is not done running yet, I can code it out and submit a pull request to the HumanUI github repo.

Hi Matthew, This thread is fine, but you’ll have to wait for Kike or @andheum, this is a bit out of my arena.

Has there been any feedback on a possible fix for that ?
Thank you