Forum

RhinoScript – Rhino.Exit doesn't work in an IF statement

I am trying to write a Rhinoscipt program to run from the command prompt that closes Rhino when it is complete. At the end of my code, I have been successfully using Rhino.Exit; however, it doesn't work when I try to use it to abort the script in case of an error.

The script below attempts to create geometry using a parameter-driven Grasshopper file. It then checks if any geometry exists, writing the current state to a flag and exiting if necessary. I have tested the code and found that the flag is correctly written as "0" if there is no geometry; but then why doesn't Rhino.Exit run?

Any help would be greatly appreciated.

Thanks,
Josh

Call Main()Sub Main()

' Auto-bake a Grasshopper file that can fail to generate geometry under certain conditions' (This is not an issue with the file and cannot always be determined in advance)