I am trying to get a response from the user by calling go.Get() . But there is no prompt? The command begins but there is no prompt.
public class RingSizeCommand : Command
{
//if you want the value metalIndex to persist, you need to define it at the class level here, not inside the RunCommand method.
private string ringSize = "6";
private int ringIndex = 6;
public RingSizeCommand()
{
// Rhino only creates one instance of each command class defined in a
// plug-in, so it is safe to store a refence in a static property.
Instance = this;
}
///<summary>The only instance of this command.</summary>
public static RingSizeCommand Instance { get; private set; }
///<returns>The command name as it appears on the Rhino command line.</returns>
public override string EnglishName => "RingSize";
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
using (var go = new GetOption())
{
RhinoApp.WriteLine("Select a ring size");
var opt = go.AddOptionList("ring sizes", RingSizes.ringSizeList, ringIndex);
go.SetCommandPrompt("Select a ring size");
//prompt for an option from the user.
var res = go.Get();
if (res == GetResult.Option)
{
RhinoApp.WriteLine("Option index: {0}", go.Option().CurrentListOptionIndex);
var option = go.Option();
ringIndex = go.Option().CurrentListOptionIndex;
}
else
{
RhinoApp.WriteLine("No option selected.");
return Result.Failure;
}
//write the ring size to the command line
RhinoApp.WriteLine("{0}, {1}", RingSizes.ringSizeList[ringIndex], RingSizes.ringSizeDict[RingSizes.ringSizeList[ringIndex]]);
double diameter = RingSizes.ringSizeDict[RingSizes.ringSizeList[ringIndex]];
RhinoApp.WriteLine("Diameter: {0}", diameter);
Circle circle = new Circle(Plane.WorldZX, diameter / 2.0);
doc.Objects.AddCircle(circle);
doc.Views.Redraw();
return Result.Success;
}
}
}
}