How to prevent canceling of RhinoApp().RunScript()

(Alexander Schiftner) #1


In my C++ plugin I am loading several RhinoScript procedures using RhinoApp().RunScript() at startup, for example I pass the following as a string to RhinoApp().RunScript():

-_RunScript (    
    Sub MyHelloWorld()
        Rhino.Print "Hello World!"
    End Sub

Afterwards I call these procedures from my plugin commands like this:

bool result = RhinoApp().RunScript(L"-_RunScript ( MyHelloWorld ))

This works perfectly well, I suppose this is also roughly the way the script compiler in Rhino 4 worked. There is just one thing I would like to achieve:

My question

How is it possible to prevent RhinoApp().RunScript being cancelled by the user using ESC?

(Dale Fugier) #2

What is your concern with the user canceling your script?

(Alexander Schiftner) #3

If the user cancels the script, it might leave the data in the Rhino document in an undefined state. Therefore I would like to prevent canceling.

(Dale Fugier) #4

Does this help?

(Alexander Schiftner) #5

Hi Dale, this certainly helps, at least it allows me to warn the user. I suspect blocking the ESC key might be possible using some C++ code, or is there absolutely no way?

(Dale Fugier) #6

Maybe. But anything else would require a modification to RhinoScript. Is it possible to re-write your script in C++?

(Alexander Schiftner) #7

Rewriting in C++ is not an option, however it would be very helpful if it were possible to create a snapshot of the Rhino-document at the beginning of the script, and roll back to it in OnCancelScript.

(Dale Fugier) #8

RhinoScript is document-centric. If you want to make stuff in memory and add it to Rhino all at one time, then you might want to look at Rhino.Python.