I would like to ask question about multiple user inputs for Rhino Command Plugin using C#
In the example below I can get string value in one input, and the second inputs gets 4 integer values.
I would like to do them not in two separate parts but in one part with 5 optional values.
string name = "CustomName";
var res = Rhino.Input.RhinoGet.GetString("ScanName", true, ref name);
RhinoUtil.Print(name);
GetOption go = new GetOption();
go.SetCommandPrompt("Set Faro scan settings");
Rhino.Input.Custom.OptionInteger HorizontalAngleMax = new Rhino.Input.Custom.OptionInteger(90 + 60, 0, 360 );
Rhino.Input.Custom.OptionInteger HorizontalAngleMin = new Rhino.Input.Custom.OptionInteger(90 - 60 , - 60, 90);
Rhino.Input.Custom.OptionInteger VerticalAngleMin = new Rhino.Input.Custom.OptionInteger(-45 ,- 60, 90);
Rhino.Input.Custom.OptionInteger VerticalAngleMax = new Rhino.Input.Custom.OptionInteger(45 , -60, 90);
go.AddOptionInteger("HorizontalAngleMin", ref HorizontalAngleMin);
go.AddOptionInteger("HorizontalAngleMax", ref HorizontalAngleMax);
go.AddOptionInteger("VerticalAngleMin", ref VerticalAngleMin);
go.AddOptionInteger("VerticalAngleMax", ref VerticalAngleMax);
Rhino.Input.GetResult get_rc = go.Get();
I suppose something like this could work (beware, I did not actually test this, but the idea should still work even though I may have made some typos )
GetOption go = new GetOption();
go.AcceptNothing(true); // when a user presses Enter, "Nothing" is returned.
string scanName = "CustomName";
int haMax = 90+60;
int haMin = 90-60;
int vaMax = 45;
int vaMin = -45;
while(true)
{
go.ClearCommandOptions();
int optScanName = go.AddOption("ScanName", scanName);
Rhino.Input.Custom.OptionInteger HorizontalAngleMax = new Rhino.Input.Custom.OptionInteger(haMax, 0, 360 );
Rhino.Input.Custom.OptionInteger HorizontalAngleMin = new Rhino.Input.Custom.OptionInteger(haMin , - 60, 90);
Rhino.Input.Custom.OptionInteger VerticalAngleMin = new Rhino.Input.Custom.OptionInteger(vaMin ,- 60, 90);
Rhino.Input.Custom.OptionInteger VerticalAngleMax = new Rhino.Input.Custom.OptionInteger(vaMax , -60, 90);
int optHorizontalAngleMin = go.AddOptionInteger("HorizontalAngleMin", ref HorizontalAngleMin);
int optHorizontalAngleMax = go.AddOptionInteger("HorizontalAngleMax", ref HorizontalAngleMax);
int optVerticalAngleMin = go.AddOptionInteger("VerticalAngleMin", ref VerticalAngleMin);
int optVerticalAngleMax = go.AddOptionInteger("VerticalAngleMax", ref VerticalAngleMax);
Rhino.Input.GetResult get_rc = go.Get();
if (get_rc == Rhino.Input.GetResult.Nothing)
break; // user pressed enter on current values
if (get_rc == Rhino.Input.GetResult.Option)
switch(get_rc.GetOptionIndex())
{
case optScanName:
var res = Rhino.Input.RhinoGet.GetString("Give scan name", ref name);
if (res != Rhino.Input.GetResult.Success)
return res; // user canceled or something went wrong.
break;
case optHorizontalAngleMax:
case optHorizontalAngleMin:
case optVerticalAngleMax:
case optVerticalAngleMIn:
haMax = HorizontalAngleMax.Value;
haMin = HorizontalAngleMin.Value;
vaMax = VerticalAngleMax.Value;
vaMin = VerticalAngleMin.Value;
default:
return Rhino.Input.GetResult.Failure; // something unexpected happened.
}