In a GetXX method, with a couple of double options, I would like that, if the user type “20” and press “enter”, the value is assigned to a specific option I choose.
It works fine with a single numeric option but it generates an error with multiple numeric options.
@software_comas, i’ve been using this way to do it:
go.AcceptNumber(True, False) to allow entering a number and put the code to setup command options in a seperate function eg. in below example this function is named
SetCommandOptions(). Then you can clear the command options after a number has been entered and run that function again eg:
while True: SetCommandOptions() get_rc = go.Get() if go.CommandResult() == Rhino.Commands.Result.Cancel: return if get_rc == Rhino.Input.GetResult.Option: option_name = go.Option().EnglishName # do something here if required elif get_rc == Rhino.Input.GetResult.Number: # set the entered number as current value for an option optSize.CurrentValue = go.Number() go.ClearCommandOptions() SetCommandOptions() else: break
Thanks a lot, Clement!
It works like a charm.