Cancel Rhino Close/Exit

I am running Rhino when I start my own application and when someone starts a design I load a file and make Rhino visible. When they close Rhino I want to hide it instead. Is it possible to catch the Rhino Close event and cancel it?

Thank you.

So here’s a link to RhinoDoc class that should have the events that you are looking for on:

http://developer.rhino3d.com/api/RhinoCommonWin/html/T_Rhino_RhinoDoc.htm

I think what you want is CloseDocument. The event arguments should allow you to cancel the closing action, but since I haven’t tested this I am only 50% sure about this.

Well, it is no problem the document closes, but rhino should not close. If I have to catch CloseDocument to cancel the exit then this is no problem. I have been looking in RhinoApp.Closing event but can’t cancel it there either.

Anyone an idea?

@dale do you know a solution?

I know of no way to keep Rhino from closing if the user chooses to close it.

– Dale

Oke thank you. Then I will keep track of the process and see if I can use runscript. If not kill the process and attach a new “background” Rhino.

I see that if I have Rhino open and use Activator.CreateInstance it will attach to the open rhino and not start a new process. Is it possible to start a new process when I create a new instance and not attach it to the open one?

EDIT: got the solution. was using. Rhino5.Interface and changed it to Rhino5.Application and now it starts a new process