@siemen wrote:
Hi guys,
Slowly digging myself into python whenever I have some time, but got stuck on this one.
So I’m making a script where I would like to receive the value from a dictionary by selecting the key in the command menu.
This is my script and I’m struggling with 3 things (see below)import Rhino Dict = { "Option1" : 111, "Option2" : 214, "Option3" : 356, "Option4" : 482, "Option5" : 514 } def GetInputFromDict(): gn = Rhino.Input.Custom.GetNumber() gn.SetCommandPrompt("Choose Number") listValues = [] for key,val in Dict.items(): listValues.append(key) listIndex = 0 opList = gn.AddOptionList("Option", listValues, listIndex) gn.Get() Number = (""" *Here I would like to get the selected value from the Optionlist* """) FinalOption = (""" *Here I would like to get the selected key from the Optionlist* """) print "You chose option" + str(FinalOption) + " which contains the number" + str(Number) + "." GetInputFromDict()
Why do I not get the same order as I have in my dictionary in my menu?
How do I make sure that after selecting one of the options in the command line I go back to this first menu but with the new option the user selected. So that it’s possible to go back into the options and choose something else.
How do I retrieve the value of the selected key from the library to be able to print the correct output
Posts: 2
Participants: 2