Check for suppression of dialogs

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.

Thanks, Larry

Hey @LarryL ,

Just to check, you want to be notified every time Rhinos Units are changed, EXCEPT if someone changed the units headlessly using a command?

Here’s a few things you should be able to use to achieve something that solves this.

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
  }

}

Thanks Callum, definitely helps!

1 Like