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

   3110   2   2
User Avatar
Member
474 posts
Joined: Dec. 2009
Offline
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!

Attachments:
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
Member
3421 posts
Joined: July 2007
Offline
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]
else:
    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
Member
2 posts
Joined: Jan. 2016
Offline
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?
  • Quick Links