I am struggling to create a simple command line option. My new command allow the user to select object and has option to enter a double.
Because my command has only 1 option, I thought what I want to do is when the user enter a number, it will update the option.
My questions are:
-
How do I update the current double options? I have added the line
else if (result == GetResult.Number) { doubleOption.CurrentValue = go.Number(); continue; }
It does update the doubleOption, but the prompt that comes up next again still got the old number.
-
When I run the same command 2nd time, is there a way to restore the last used Double Option?
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
// For this example we will use a GetPoint class, but all of the custom
Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject();
go.SetCommandPrompt(“Select closed curve”);// set up the options Rhino.Input.Custom.OptionDouble doubleOption = new Rhino.Input.Custom.OptionDouble(50); go.AddOptionDouble("Double", ref doubleOption); go.AcceptNumber(true, true); go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; go.GroupSelect = true; go.SubObjectSelect = false; go.EnableClearObjectsOnEntry(false); go.EnableUnselectObjectsOnExit(false); go.DeselectAllBeforePostSelect = false; go.EnableSelPrevious(true); go.EnablePreSelect(true, false); go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; bool bHavePreselectedObjects; while (true) { // perform the get operation. This will prompt the user to select the list of curves, but also // allow for command line options defined above GetResult result = go.GetMultiple(1, 0); if (result == GetResult.Option) { go.EnablePreSelect(false, true); continue; } else if (result == GetResult.Number) { doubleOption.CurrentValue = go.Number(); continue; } else if (result != GetResult.Object) { return Result.Cancel; } if(go.ObjectsWerePreselected) { bHavePreselectedObjects = true; go.EnablePreSelect(false, true); continue; } break; } int objecTCount = go.ObjectCount; return Result.Success;
}