Dynamic menu of choices

   4252   7   1
User Avatar
Member
2624 posts
Joined: Aug. 2006
Offline
Hi All ,
Is it at all possible to create a menu of choices other than a ordered list that returns token values of 0 , 1 , 2 etc etc .
The scene attached shows a Null reading in some data from a volume. Based on those values I wanted to give the user a choice to be able to select a choice like Size X / Volumeres Z or Size Y / Volumeres Z . Is this sort of thing possible ? . I would welcome some help !

Rob

Attachments:
VolumeStepSizeCalculator.hip (256.4 KB)

Gone fishing
User Avatar
Member
678 posts
Joined: July 2005
Offline
Check info about “menu script” in help. If I understand it correctly this is what you are looking for.

From help.

Choose “Menu script” to specify the list of token/value pairs using a script. Use this option if the contents of the list change based on the current conditions in Houdini (for example, a menu that lets you choose from the currently selected objects).
User Avatar
Member
2624 posts
Joined: Aug. 2006
Offline
Do you happen to have an example of that working ? , I did take a look at it but came to a full stop.

rob
Gone fishing
User Avatar
Member
678 posts
Joined: July 2005
Offline
This is rather straight forward.

Play with radius in attached file. Look how available menu options changes when it's smaller or equal 2 and when it's bigger than 2.

Attachments:
example.hipnc (240.7 KB)

User Avatar
Member
792 posts
Joined: April 2020
Offline
when using python this is really simple. you create a list of pairs of labels and tokens, for example:

list =

for choice in :
….list +=

return list

Hope that helps,
koen
User Avatar
Member
2624 posts
Joined: Aug. 2006
Offline
Hi Koen,
I'm by no means a python user would it be possible to get an example file for all to see.Based on the scene file I posted. I didnt know you could use python with adjusting a parameter interface. Starting with something basic like this would be pretty useful.

Rob
Gone fishing
User Avatar
Member
1921 posts
Joined: Nov. 2006
Offline
My first thought looking at your file was that I really only needed to build a dynamic menu of incoming volume primitives.

In the attached, modified file, I've replaced the menu with a dynamically created one that just grabs all the input prims and creates a menu with their numbers. The size and resolution ones behave the same as before but I just did it all using Python for consistency. I then just created 2 new menus, both with choices of XYZ to select a size and resolution. The step size is then just the same calculation as the original but using the chosen axes instead.

Menu scripts are really great, especially since you can easily do them using Python, but they really present a challenge when you set the token to be a not ordered number. There is no real way to get that string value.

For example I can make a menu that is . Now if I want to get the value of the menu all I will ever be able to get back from Houdini is 0 or 1, the selected index. Even evalAsString() will return ‘0’ or ‘1’ due to the nature of the scripted menu. If it was a manually created menu it would be fine. There is also a bug where hou.Parm.menuItems() fails in 10.0 when the menu is a script. If you can get a tuple of the items then you can easily get the actual string token using the value to index into the list. The bug is fixed in the next version of Houdini.

In this example it's pretty straight forward and you don't run into any problems, but if you were to have non-volume primitives in your input geometry as well you would run into this problem trying to separate them out for the menu and then retrieve the actual selected one to be used in the calculations.

Attachments:
volumestepsizecalculator_398.hipnc (253.2 KB)

Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
2624 posts
Joined: Aug. 2006
Offline
Hi Graham ,
I have tried to replicate your file but even copying and pasting gives me this error.

Error evaluating autocompletion:
“ File \”<stdin>\“, line 1
__import__('houdiniInterpreter').getCallTipOrAutoCompleteArgumentsList('prim_num = pwd().evalParm(\”prim\")
^
SyntaxError: EOL while scanning single-quoted string

When trying to get the volume resolution. If I take your file delete the values for the volume resolution then paste in the exact same python I get the same error. I made sure there were no extra spaces etc etc .

Any ideas ?


Rob
Gone fishing
  • Quick Links