Jump to content
salik

Setting options in drop-down menu

Recommended Posts

Hi all, I apologize if this is a noob question. Currently I am trying to find out how to change the options in a drop-down menu.

Say if there are 3 options, and I am trying to set the option to the second option, I tried doing

node.parm('resolution').set(1)

I got the following errors:

    return _hou.Parm_set(*args)
TypeError: Cannot set a string parm to a int

But if I tried to replace `1` with the string value of the second option, while there are no errors to be seen, the option in the drop down did not get change to the second option at all, it is still stuck at the default option.

Any ideas?

Share this post


Link to post
Share on other sites
int_menu_parm.set(1)            # Switches to second menu item i1.
int_menu_parm.set('2')          # Switches to third menu item i2.
int_menu_parm.set('i0')         # TypeError: Cannot set a numeric parm to a non-numeric value.
int_menu_parm.set(1000)         # Sets parm to integer 1000, fallbacks to i0.

string_menu_parm.set(1)         # TypeError: Cannot set a string parm to a int
string_menu_parm.set('2')       # Sets parm to string '2', fallbacks to i0.
string_menu_parm.set('i0')      # Switches to first menu item i0.
string_menu_parm.set(1000)      # TypeError: Cannot set a string parm to a int

ordered_menu_parm.set(1)        # Switches to second menu item i1.
ordered_menu_parm.set('2')      # OperationFailed: The attempted operation failed. Invalid menu item.
ordered_menu_parm.set('i0')     # Switches to first menu item i0.
ordered_menu_parm.set(1000)     # Sets parm to integer 1000, fallbacks to i0.

You can inspect correct menu tokens if you open Edit Parameter Interface window.

 

Same applies to VEX: numbers for integer menus, token names for string menus, both for ordered menus.

Edited by f1480187

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×