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.
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
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 @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.