Remove One Command Option or List Current Options

I am writing a class derived from GetPoint; it adds a command option via AddOption(string, string). Once the caller starts selecting points I want to remove that option as it is no longer applicable. ClearCommandOptions will remove all options, but if this custom GetPoint class is being used by a command that happened to add other options in the command, I don’t want to inadvertently clear those options.

(a) Does this make sense?
(b) Is there a way to delete a single command option or enumerate the current options so I can restore them after calling ClearCommandOptions?

Thanks, Larry

Hi @LarryL,

There isn’t a way to remove a single option from a RhinoGet class. Just add your options inside of a while (true) loop:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  var show = false;
  var showOption = new OptionToggle(show, "No", "Yes");

  var gp = new GetPoint();
  gp.SetCommandPrompt("Base point");
  while (true)
  {
    gp.ClearCommandOptions();

    var showIndex = gp.AddOptionToggle("Show", ref showOption);
    var testIndex = show ? gp.AddOption("Test") : -1;

    var res = gp.Get();

    if (res == GetResult.Option)
    {
      var opt = gp.Option();
      if (opt.Index == showIndex)
        show = showOption.CurrentValue;
      else if (opt.Index == testIndex)
        RhinoApp.WriteLine("Test option selected");
      continue;
    }

    else if (res != GetResult.Point)
      return Result.Cancel;

    break;
  }

  // TODO...

  return Result.Success;
}

– Dale

Hi Dale. Thanks for that input.

That works fine if I am the writer of the command and am adding options. But if I am writing the custom GetPoint class and inside MyGetPoint class I add an option, I have know way of knowing if the caller of MyGetPoint (i.e., the command) added options as well. It would be nice if I could query the MyGetPoint to make sure I don’t do something to them.

No big deal, just a thought for the future.

Thanks, Larry