(Declan Halpin) #1

Hi all,

I’m going to go ahead and apologize for being a noob, and also for the fact that I can’t post my code because it is work-related. Hopefully I can describe my issue well enough…

I have a .rs that prompts the user to select some parts. The selection is evaluated: “If Not IsNull(ArrObjects) Then…” and the parts are put on a specific layer. The script then asks the user for a second set which are put on a specific layer, and a third set.

What I’m trying to do is enable the Esc key to bail out of the script by using OnCancelScript, which I’ve figured out. But I also want to enable the Enter key to skip over selection set 1 (sometimes that set is not present). Unfortunately, I’m calling OnCancelScript via the IsNotNull / Else which is also triggered by Enter.

So I don’t have a way to differentiate Esc from Enter. Does that make sense?

And on a related note, how to I get OnCancelScript to simply exit the script. Is there no “Quit Script” or “Exit” etc?

Thanks in advance!!


Hi Declan,

Not sure if I understand right without seeing some code snippet, but in general you don’t need to call OnCancelScript from your code. As long as this routine exists in your script, it will kick in when the script gets canceled via Esc by the user (but not by programmed ending of script or Exit Sub/Function).

Does it make sense?


(Dale Fugier) #3

Hi @declan,

A sample from the help file:

Sub TightLoopEscapeTest
  For i = 0 to 100000
    Call Rhino.Print(i)
    Call Rhino.Sleep(0)
End Sub

' User-defined cancel script handler
Sub OnCancelScript
  ' Do script cancelling operations here...
  Call MsgBox("Script Cancelled!", vbOkOnly + vbExclamation, "RhinoScript")
End Sub

– Dale


Unfortunately, Rhinoscript does not offer a direct way to differentiate between Esc and Enter (with nothing selected) when picking objects… RhinoCommon does…

(Declan Halpin) #5

Thanks guys! All good info. It looks like I’ll need to re-write this in python (after I learn it, lol).

Happy Friday everyone!