Jump to content

Setting options in drop-down menu


salik

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?

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...