Something to keep in mind is that OnDynamicDraw is called every time the mouse moves. So you’re just printing the same number over and over again, even though the user hasn’t specified a number.
I want to be notified when input is changed and then draw something dynamically, do you have any suggestion about implementing it?
By the way, OnDynamicDraw will be called after input is changed and mouse not move at the same time.
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var number = 3.14159;
var go = new GetPoint();
go.SetCommandPrompt("Pick point location");
go.AcceptNothing(true);
while (true)
{
go.ClearCommandOptions();
var opt_number = new OptionDouble(number);
var idx_number = go.AddOptionDouble("Number", ref opt_number);
var result = go.Get();
if (result == GetResult.Option)
{
var option = go.Option();
if (idx_number == option.Index)
number = opt_number.CurrentValue;
RhinoApp.WriteLine("Number set to {0}", number);
continue;
}
if (result == GetResult.Point)
{
doc.Objects.AddPoint(go.Point());
doc.Views.Redraw();
}
if (result != GetResult.Nothing)
return Result.Cancel;
break;
}
return Result.Success;
}
I want to do dynamically drawing before user pressing enter, and your code update view after user pressing enter. The goal is similar with builtin function Circle, when user input new radius without press enter, the circle will be updated with new value.
For Circle command, the circle will be updated/redraw after change the value, no need to press enter
For sample, the circle only be updated/redraw after press enter.
So Circle command is better for user previewing the result before add circle to document