private void ExecuteIntoGH()
{
RhinoApp.RunScript("MyData_Into_Grashopper", true);
// if that was successful then open GH
RhinoApp.RunScript("_Grasshopper", false);
}
So if this is running outside of a Command, the script will return immediately, and then your script will run, so you cannot rely on it for a “result”.
If you want things to execute synchronously, you will need them chained together in the same command if using RunScript. e.g.
If you need there to be logic to determine if it should continue, you will likely need the first command to modify some kind of state in your plugin, and then check that state with another command before proceeding.
RhinoApp.RunScript returns a bool indicating whether or not Rhino ran your script. However, this is not an indication of whether or not the command completed successfully.
The RunCommand method of Rhino commands, classes that inherit from Commands.Command, return a Commands.Result value indicating if the command finished successfully, was canceled by the user, had some sort of unexpected failure, etc. This Result is determined by the command’s developer.
I’ve realised how much nuance there is around this and I’ll definitely need to do some proper event handling at some point.
For this really simple case (not opening Grasshopper is more a UX choice because what’s the point in seeing it if it hasn’t been properly populated) @jstevenson 's solution worked very nicely.