Eat up unused options


#1

Hi,

I have a picker (derived from CRhinoGetPoint) with a toggle option (say _Opt with value labels _Off and _On). And I have a command which uses this picker. My command can be run like that: _MyCommand _Opt=_Off.

In case of pre-selection, I don’t use my picker; thus the option _Opt is not used.

My problem is that, when running _MyCommand _Opt=_Off with a pre-selection, the string _Opt=_Off is not used and, when my command tries to run a Rhino command, it runs _Opt=_Off instead.

So, I’m looking for a way to “eat up” this unused option. I have tried the following:

  CRhinoGetObject dummyPicker;
bool dummyVal = true;
dummyPicker.AddCommandOptionToggle (
    RHCMDOPTNAME (L"Opt"),
    RHCMDOPTVALUE (L"Off"),
    RHCMDOPTVALUE (L"On"),
    dummyVal, &dummyVal);
dummyPicker.EnablePreSelect(true);
dummyPicker.EnablePostSelect(false);
dummyPicker.GetObjects();

but it doesn’t skip the option string _Opt=_Off.

Has anyone any solution?

Thanks,
Jean


(Dale Fugier) #2

Hi Jean,

How about this:

bool b = true;

CRhinoGetObject go;
go.SetCommandPrompt( L"Select object" );
go.AddCommandOptionToggle( RHCMDOPTNAME (L"Opt"), RHCMDOPTVALUE (L"Off"), RHCMDOPTVALUE (L"On"), b, &b );
go.EnablePreSelect(true);
go.GetObjects( 1, 1 );
if( go.CommandResult() != CRhinoCommand::success )
  return go.CommandResult();

if( go.ObjectsWerePreSelected() )
{
  CRhinoGetOption gt;
  gt.SetCommandPrompt( L"Option" );
  gt.AddCommandOptionToggle( RHCMDOPTNAME (L"Opt"), RHCMDOPTVALUE (L"Off"), RHCMDOPTVALUE (L"On"), b, &b );
  gt.GetOption();
  if( gt.CommandResult() != CRhinoCommand::success )
    return gt.CommandResult();
}

RhinoApp().Print( L"Opt = %s\n", b ? L"On" : L"Off" );

#3

Hi Dale,

Yes, I’ve also tried something like this but it requires an extra _Enter in case of pre-selection.

Thanks anyway,

Jean