HDA, Button Strip, menu script : can't retrieve the tokens ?

   886   2   0
User Avatar
Member
123 posts
Joined: 5月 2015
Offline
Hey,

I'm creating a custom dynamic button strip menu on my HDA, no issues : I get one button per dynamic entry as instructed.
The issue I have is that I can't then, using a callback, retrieve the list of tokens, as noted by the doc, as such :

def strip_to_tokens(parm):
    # Takes a reference to a button/icon strip parameter
    # instance and returns a list of tokens corresponding
    # to the buttons that are on

    bitfield = parm.eval()
    tokens = parm.parmTemplate().menuItems()
    return [token for n, token in enumerate(tokens) if bitfield & (1 << n)]

This will return an empty list.
The thing is that when setting up a fixed menu using the 'menu items' tab instead of 'menu script', this little bit of code will correctly return the tokens. It seems the dynamic nature of my button strip parameter is the culprit, and both parmTemplate().menuItems() and parmTemplate().menuLabels() are returning empty strings.

Is there something I'm missing ?
It looks like I'll have to also rebuild the source list in the callback.
Edited by Wolrajh - 2023年1月9日 12:26:06
User Avatar
Member
1906 posts
Joined: 11月 2006
Offline
Since your menu is being dynamically generated, you need to query the menu items directly from the hou.Parm object and not it's parmTemplate.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
123 posts
Joined: 5月 2015
Offline
graham
Since your menu is being dynamically generated, you need to query the menu items directly from the hou.Parm object and not it's parmTemplate.

Oh god. Sometimes it's just here, right under your nose. Just parm.menuItems(), of course... ughh !

Thanks Graham. Just needed a tap on the head apparently
  • Quick Links