Python state dynamic menu - multiparm instances.

   1782   5   1
User Avatar
Member
39 posts
Joined: Jan. 2012
Offline
I am attempting to create a modal menu that updates it's contents based on the currently highlighted primitive in a viewer state.

The data on the node is a multiparm string menu of options, where each instance of the multiparm is driven by script. So each prim contains different options in the menu script;

prim0 = “OptionA”, “OptionB”
prim1 = “OptionA”
prim2 = “OptionC”, “MyOtherOption”


Is it possible to build a menu in a viewer state dynamically?

I have looked into onMenuPreOpen(), which gives me the access to setting parms on an existing menu, but I cannot seem to build/update an existing one with addRadioStripItem() as I can't grab the menu object.


Any thoughts? Any other approaches to look at? Could I bind a menu parm instead?

Cheers,
Aaron.
Edited by aaronauty - April 22, 2020 07:18:40
www.aaronauty.com
User Avatar
Staff
400 posts
Joined: Feb. 2018
Online
Dynamic menus are not supported at the moment, there is an RFE logged for that.
User Avatar
Member
39 posts
Joined: Jan. 2012
Offline
OK great to hear, looking forward to it.

I am going to use the mouse-wheel and a hou.Drawable() to show the text for now.

Cheers.
www.aaronauty.com
User Avatar
Staff
400 posts
Joined: Feb. 2018
Online
You can also fake a dynamic menu by updating the menu item label and visible states. I'm backporting a fix for that to H18.0, it should be available in the daily builds tomorrow.
User Avatar
Member
65 posts
Joined: March 2017
Offline
Hi mabelzile,

I was looking for something similar, could you explain how to implement this ?

I was also thinking that maybe I could implement a hou.parmTemplateType.String. When I right click on it I get “No Options Available”. Is there a way to dynamically populate Options for this ?

Thanks a lot in advance,

Julien
Edited by julien-b - April 28, 2020 17:38:11
VFX Supervisor @ MPC London
User Avatar
Staff
400 posts
Joined: Feb. 2018
Online
You can update the python state context menu with onMenuPreOpen which is called before the menu opens up when you RMB. For instance, you could create your context menu with all possible menu items you want to support. Then in onMenuPreOpen you can decide which menu items you want visible or change labels, etc… (see attached example)
Image Not Found


State dynamic parameter menu is not yet supported.
Edited by mabelzile - April 29, 2020 11:35:50

Attachments:
menu_pre_open_test.hip (72.0 KB)

  • Quick Links