I’m seeing what looks like an inconsistency with GetOption.AddOptionList.
In the sample below:
- adding list values containing spaces fails, which I expected
- adding list values without spaces and with punctuation succeeds, which I also expected
- clicking the option in the command line shows the full list, and I can pick any value
- but pressing
Lthen space shows a shortened list in the command window, containing only the two values without punctuation
I understand that Rhino command input generally does not like spaces, except in cases like GetLiteralString, and it often has limitations around punctuation. That part is fine.
What seems inconsistent is that the first AddOptionList call correctly reports failure when the values contain spaces, while the second call reports success with punctuation. The mouse UI also shows the punctuation values correctly. But when using the keyboard to access the list, the values with punctuation appear to be silently removed from the available choices.
Is this expected behavior, or should AddOptionList reject those values up front if they are not valid for keyboard input?
I’d like to hear from experienced plugin developers on how they handle this when camel case feels too restrictive.
Sample code:
import Rhino
from Rhino.Input.Custom import GetOption
from Rhino.Input import GetResult
getter = GetOption()
getter.SetCommandPrompt("GetOption test")
values = ["OnlyWords", "With.punctuation", "With space", "OnlyWordsAgain"]
if not getter.AddOptionList("ListOfValues", values, 0):
print("Failed to add option list with spaces")
getter = GetOption()
getter.SetCommandPrompt("GetOption test")
values = ["OnlyWords", "With.punctuation", "OnlyWordsAgain"]
if not getter.AddOptionList("ListOfValues", values, 0):
print("Failed to add option list without spaces")
result = getter.Get()
if result == GetResult.Option:
option = getter.Option()
Rhino.RhinoApp.WriteLine(f"Selected option index: {option.Index}")
Rhino.RhinoApp.WriteLine(f"Selected list index: {option.CurrentListOptionIndex}")
Rhino.RhinoApp.WriteLine(f"Selected value: {values[option.CurrentListOptionIndex]}")
else:
Rhino.RhinoApp.WriteLine(f"Result: {result}")