Update issue // SR 13 // Script broken with event change


I am using the event “Grasshopper.Instances.DocumentServer.DocumentRemoved +=” inside a c# script component to write a text document when the grasshopper definition is close in order to understand if this particular file is open or closed.

After the latest Service Release 13 of Rhino and release of grasshopper 1.0.0007 the event does not seem to execute any more. Was a feature added that could have altered the behavior?

it’s possible i am using this event incorrectly or there is a better way.

Here is the code I’m using:

if (S == true)
      string open = "Open";
      System.IO.File.WriteAllText(@"C:\Temp\openClosed.txt", open);

      Grasshopper.Instances.DocumentServer.DocumentRemoved += FooOff;

void FooOff(GH_DocumentServer sender, GH_Document doc)
    string Off = "Off";
    System.IO.File.WriteAllText(@"C:\Temp\openClosed.txt", Off);

Here is a link to the specific event I’m using when grasshopper is closed


After some further testing with another person upgrading, I think this is due to the Rhino update and not to something on the grasshopper side. I’m switching groups to see if it gains any traction.

Hi @nbarnes,

sometimes there are issues with updates. We will be thankful for any help discovering them.

Do you have a code sample that can reproduce this problem in SR13?
I tried the following in Version 6 SR15 early Release Candidate codestream and there seems to be no issue.

foo-remove.gh (1.3 KB)




Giulio Piacentino
for Robert McNeel & Associates

I can’t repeat it either using the attached file, however it is possible that another event handler which gets called before yours is throwing an exception. I think that would prevent further handling (more testing required).

document removal event.gh (2.4 KB)

Yeah that’s probably what’s happening here. Some other handler is not playing nice and screwing it up for the rest of us.


I’m pretty new to using events, I wasn’t sure what to look into when this was not able to execute. But it looks like you are correct David. I should have done a more thourough testing but I did a clean reinstall and the event is back working.

Thanks @piac and @DavidRutten