how to get the "label" of an item in ordered menu

   4903   2   2
User Avatar
476 posts
Joined: Dec. 2009
I have an ordered menu with each of its “Token” associated with a string “Label”. (image 08 )

May I ask how can I use either Hscript or Python to get the Label string once I select an item from the menu?

I tried the following but it always return the numerical index or the token value of the menu item selected … (image 09 & 10)

Thank you very much!

08.JPG (56.0 KB)
09.JPG (16.0 KB)
10.JPG (13.1 KB)

It's always a pleasure to learn from you!
User Avatar
4183 posts
Joined: July 2007
something like this:
parm = hou.pwd().parm("case_name_list")
value = str(parm.eval())  # convert to string since you have ordered menu
if value in parm.menuItems(): 
    index = parm.menuItems().index(value)
    return parm.menuLabels()[index]
    return "value %s not found in menu" % value

EDIT: updated formatting as it was lost over time
Edited by tamte - July 11, 2018 12:44:58
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
2 posts
Joined: Jan. 2016
let's take above example where i have same menu and here i want to list my directory in that menu with same labels & token how we can do that?
Double Negative
  • Quick Links