partialclassExamples{publicstaticRhino.Commands.ResultCommandLineOptions(Rhino.RhinoDoc doc){// For this example we will use a GetPoint class, but all of the custom// "Get" classes support command line options.Rhino.Input.Custom.GetPoint gp =newRhino.Input.Custom.GetPoint();
gp.SetCommandPrompt("GetPoint with options");// set up the optionsRhino.Input.Custom.OptionInteger intOption =newRhino.Input.Custom.OptionInteger(1,1,99);Rhino.Input.Custom.OptionDouble dblOption =newRhino.Input.Custom.OptionDouble(2.2,0,99.9);Rhino.Input.Custom.OptionToggle boolOption =newRhino.Input.Custom.OptionToggle(true,"Off","On");string[] listValues =newstring[]{"Item0","Item1","Item2","Item3","Item4"};
gp.AddOptionInteger("Integer",ref intOption);
gp.AddOptionDouble("Double",ref dblOption);
gp.AddOptionToggle("Boolean",ref boolOption);int listIndex =3;int opList = gp.AddOptionList("List", listValues, listIndex);while(true){// perform the get operation. This will prompt the user to input a point, but also// allow for command line options defined aboveRhino.Input.GetResult get_rc = gp.Get();if(gp.CommandResult()!=Rhino.Commands.Result.Success)return gp.CommandResult();if(get_rc ==Rhino.Input.GetResult.Point){
doc.Objects.AddPoint(gp.Point());
doc.Views.Redraw();Rhino.RhinoApp.WriteLine("Command line option values are");Rhino.RhinoApp.WriteLine(" Integer = {0}", intOption.CurrentValue);Rhino.RhinoApp.WriteLine(" Double = {0}", dblOption.CurrentValue);Rhino.RhinoApp.WriteLine(" Boolean = {0}", boolOption.CurrentValue);Rhino.RhinoApp.WriteLine(" List = {0}", listValues[listIndex]);}elseif(get_rc ==Rhino.Input.GetResult.Option){if(gp.OptionIndex()== opList)
listIndex = gp.Option().CurrentListOptionIndex;continue;}break;}returnRhino.Commands.Result.Success;}}
importRhinoimport scriptcontext
defCommandLineOptions():# For this example we will use a GetPoint class, but all of the custom# "Get" classes support command line options.
gp =Rhino.Input.Custom.GetPoint()
gp.SetCommandPrompt("GetPoint with options")# set up the options
intOption =Rhino.Input.Custom.OptionInteger(1,1,99)
dblOption =Rhino.Input.Custom.OptionDouble(2.2,0,99.9)
boolOption =Rhino.Input.Custom.OptionToggle(True,"Off","On")
listValues ="Item0","Item1","Item2","Item3","Item4"
gp.AddOptionInteger("Integer", intOption)
gp.AddOptionDouble("Double", dblOption)
gp.AddOptionToggle("Boolean", boolOption)
listIndex =3
opList = gp.AddOptionList("List", listValues, listIndex)whileTrue:# perform the get operation. This will prompt the user to# input a point, but also allow for command line options# defined above
get_rc = gp.Get()if gp.CommandResult()!=Rhino.Commands.Result.Success:return gp.CommandResult()if get_rc==Rhino.Input.GetResult.Point:
point = gp.Point()
scriptcontext.doc.Objects.AddPoint(point)
scriptcontext.doc.Views.Redraw()
print "Command line option values are"
print " Integer =", intOption.CurrentValue
print " Double =", dblOption.CurrentValue
print " Boolean =", boolOption.CurrentValue
print " List =", listValues[listIndex]elif get_rc==Rhino.Input.GetResult.Option:if gp.OptionIndex()==opList:
listIndex = gp.Option().CurrentListOptionIndexcontinuebreakreturnRhino.Commands.Result.Successif __name__ =="__main__":CommandLineOptions()
PartialClassExamplesPublicSharedFunctionCommandLineOptions(ByVal doc AsRhino.RhinoDoc)AsRhino.Commands.Result' For this example we will use a GetPoint class, but all of the custom' "Get" classes support command line options.Dim gp AsNewRhino.Input.Custom.GetPoint()
gp.SetCommandPrompt("GetPoint with options")' set up the optionsDim intOption AsNewRhino.Input.Custom.OptionInteger(1,1,99)Dim dblOption AsNewRhino.Input.Custom.OptionDouble(2.2,0,99.9)Dim boolOption AsNewRhino.Input.Custom.OptionToggle(True,"Off","On")Dim listValues AsString()=NewString(){"Item0","Item1","Item2","Item3","Item4"}
gp.AddOptionInteger("Integer", intOption)
gp.AddOptionDouble("Double", dblOption)
gp.AddOptionToggle("Boolean", boolOption)Dim listIndex AsInteger=3Dim opList AsInteger= gp.AddOptionList("List", listValues, listIndex)WhileTrue' perform the get operation. This will prompt the user to input a point, but also' allow for command line options defined aboveDim get_rc AsRhino.Input.GetResult= gp.[Get]()If gp.CommandResult()<>Rhino.Commands.Result.SuccessThenReturn gp.CommandResult()EndIfIf get_rc =Rhino.Input.GetResult.PointThen
doc.Objects.AddPoint(gp.Point())
doc.Views.Redraw()Rhino.RhinoApp.WriteLine("Command line option values are")Rhino.RhinoApp.WriteLine(" Integer = {0}", intOption.CurrentValue)Rhino.RhinoApp.WriteLine(" Double = {0}", dblOption.CurrentValue)Rhino.RhinoApp.WriteLine(" Boolean = {0}", boolOption.CurrentValue)Rhino.RhinoApp.WriteLine(" List = {0}",listValues(listIndex))ElseIf get_rc =Rhino.Input.GetResult.[Option]ThenIf gp.OptionIndex()= opList Then
listIndex = gp.[Option]().CurrentListOptionIndexEndIfContinueWhileEndIfExitWhileEndWhileReturnRhino.Commands.Result.SuccessEndFunctionEndClass