Is there a preferred way to check to see if a currently running command (that is not my own command) was run with a hyphen to suppress UI dialogs? I handle an event that occurs when the user changes units in Rhino. That event opens a form unless Command.InScriptRunnerCommand() || Rhino.Runtime.HostUtils.RunningAsRhinoInside || RhinoApp.IsRunningAutomated but none of these conditions are true when a user runs
-DocumentProperties to change the units.
Here’s some rough code that may help, although I haven’t tested it.
private void OnCommandRun(object sender, CommandEventArgs args)
{
var commandName = args.CommandEnglishName;
var recentCommands = RhinoApp.GetMostRecentCommands();
foreach(var recentCommand in recentCommands)
{
if (!recentCommand.Macro.Contains("-")) continue;
if (!recentCommand.DisplayString.Equals(commandName, StringComparison.OrdinalIgnoreCase)) continue;
// ... Do your thing here
}
}