OnCancelScript

Hi all,
How can I cancel a command of a RVB file?

I have used method:
OnCancelScript
But in some cases it does not work

kind:
rhino.AddLine rhino.GetPoint, rhino.GetPoint
After the first point if I press ESC I by mistake

Can cancel the command without error message?

Hi @0904,

if you put your code into a subroutine, you can exit that subroutine whenever a variable does not meet a condition. Eg. if the return value of Rhino.GetPoint is Null because you pressed ESC during the prompt:

Option Explicit

Call Main()
Sub Main()
    
    Dim arrPoint_A, arrPoint_B
    
    arrPoint_A = Rhino.GetPoint("First Point")
    If IsNull(arrPoint_A) Then Exit Sub
    
    arrPoint_B = Rhino.GetPoint("Second Point")
    If IsNull(arrPoint_B) Then Exit Sub
    
    Rhino.AddPoint arrPoint_A
    Rhino.AddPoint arrPoint_B

End Sub

OnCancelScript() is not a RhinoScript method and serves a different purpose, it can be used if a tight loop is stopped using the ESC key. An example is shown here.

_
c.

So it only works with loops
Ok. I can’t undo a script
Thank you Clement