Close GH Player definition

@AndyPayne
I’m glad you’ve addressed the issue of using add-ons like Human UI with Grasshopper Player, it’s very important.

The general problem to solve is that after using HumaniUI-based Grasshopper definitions preview still exists.
I think we need a component that specifically closes the Grasshopper definition, current solutions are not enough.
I tried various workarounds to turn off at least the GH preview after bake, but while these solutions worked properly in Grasshopper, using Grasshopper Player unfortunately not anymore.
Besides, do such unclosed definitions accumulate somewhere in the memory?

Metahopper solution to turn off preview after HumanUI bake - works only in GH, not in GH Player

This is how it looks using GH Player. Metahopper workaround to disable GH Preview doesn’t work anymore

Does selecting the option to “close the file after GH Player runs” (in the Document Properties) not close the file for you? Or are you saying that you want a different way to close the file when it’s run through the command line?

I need a different way to close the file.
I’m using Human UI with Grasshopper Player so I can’t use “close the file after GH Player runs”. If I understood correctly you made that option so the user can disable it when using Human UI :slight_smile: .

However, when I finish with my Human-UI GH Player script, there is no way to close it. Even if I close the window, GH preview still exists.
I need some kind of boolean to close the GH definition so I can attach this boolean to the Human UI button.

In short I need “exit” button functionality

Hello,
Any news about it?
Thank you

It is such an option somewhere? Just checked the properties and I cand find this option.

Is is available for Grasshopper in Rhino 8

@AndyPayne @Will_Wang

Ok, I’m trying Synapse now which is very cool, we can expand it ourselves by writing some Eto forms for it, even Rhino viewport! I went far with my test, but this limitation hits harder now than it was while using the Human UI… BTW I highly recommend the Synapse plugin, I don’t know how it went under my radar for such long.

There must be some way to terminate the underlying GH definition while using Grasshopper Player or compiled Grasshopper scripts.

In this video, you can see that the old definition keeps on coming back. This will not happen if I use this definition in a regular way (just opening it in Grasshopper). I can even close the GH file by the script, but I can’t do it while using the Grasshopper Player. In the video I’m trying to use this script but as you can see nothing happens.

One of the buttons from the Synapse GUI is connected to the very simple script which I hoped would close the underlying Grasshopper definition but it’s not.

import Rhino as rc

if Close:
    ghp = rc.RhinoApp.GetPlugInObject("Grasshopper")
    ghp.CloseDocument()

So the issue stands exactly how it was. On the one hand, I must use “Keep open after command completes” to be able to use the GUI but also I must be able to close it, because the junk piles up and script is coming back.


One of the possible issues of not closing the previously used GH Player script - not only it initialize itself here, but did it twice.

Necessary GH document properties set to be able to use the created GUI - blessing and poison at the same time.
image

This is what happens if the toggle from the screenshot above is not enabled. I would be happy if I could do it on purpose.
image

Maybe this hack can work
You can write a script that disables the show window component after the first solution computed. This way when an action in Rhino triggers a new GH solution, that component wouldn’t re-initiate the window.
I haven’t played with the GH player too much so not sure if this will blow up something else…

1 Like

Just putting in my 2c here.

For my current projects - Rhino plugins, built in GH and compiled using the Script Compiler - this has been an ongoing ‘bug’.

I currently opt to close Rhino completely if my user chooses to close my plugins UI.

Ideally I’d like a McNeel supported option to cleanly close the GH instance that is running my code.

I would have a few things that need to be cleaned up before GH closes, so a Script Context or Rhino Common method I can call from GH Python is preferred.

Cheers

DK

1 Like

Hah, nice workaround, the first test went positive. Thanks!
This only destroys the UI, so one problem might be “solved” this way.
I can take care to disable the rest of my script so it will not compute anything.

and there are still Grasshopper Preview leftovers which in some cases could even be useful but I would expect McNeel to provide some robust methods to take control of this mess. It’s really worrying that there might be dozens of gh definitions opened in the background.
I just want to close them.

@kiteboardshaper
That’s why I asked you in another topic if you do something extra to close your compiled definitions. :slight_smile:


Similar thread:

Just pulling this thread back to the top.

Has anyone found a solution to finish/close cleanly a grasshopper player/rhino script compiler plugin?

I’m still using the route of closing Rhino completely - but this only works OK in Windows.

I would prefer an option that allows my plugin to close and the user to still keep using Rhino.

Cheers

DK

Unfortunately no, and looks like McNeel has added some features toward this goal only in Rhino8 and up. If you are still using Rhino7 like me, bad luck.