Is there a way to get result from programmatic command invocation?


#1

Is there a way to retrieve the return value when a command is invoked via RhinoApp.RunScript?

If not, is there another way to invoke commands with RhinoCommon?


(Menno Deij - van Rijswijk) #2

You can subscribe to the Command.EndCommand event (see http://4.rhino3d.com/5/rhinocommon/html/E_Rhino_Commands_Command_EndCommand.htm) This has CommandEventArgs as event arguments, in which you find CommandResult

http://4.rhino3d.com/5/rhinocommon/html/T_Rhino_Commands_CommandEventArgs.htm

So, subscribe an event handler to EndCommand prior to running with Runscript. Ensure that the command that ends is indeed the command from runscript (compare name). Then you know the result. Lastly: unsubscribe the event handler.