menu from switch input node names

   6399   9   2
User Avatar
Member
13 posts
Joined: Oct. 2009
Offline
How would I create a menu that controls updates based on the switch it controls inputs node names? For instance I have a switch that has several uv edit nodes that control uv placement so one can choose A, B, C texture swatches on a texture page. I have the Digital Asset copied hundreds of times through a stamp on a switch so If I eventually want to add a texture D, E, and F, I would need to manually update hundreds of menu's. Is there a way to have it update based on how many inputs and names of nodes coming into a switch?
User Avatar
Member
8053 posts
Joined: July 2005
Offline
Your HDA menu parameter can have its contents generated via a script.

http://www.sidefx.com/docs/houdini12.0/hom/assetscripts#parameter_menu_scripts [sidefx.com]
User Avatar
Member
13 posts
Joined: Oct. 2009
Offline
It looks like what I need to use is the hou.Node.input but not sure how to point it at the switch that I need to find the inputs on. Any suggestions or examples would be appreciated.
User Avatar
Member
8053 posts
Joined: July 2005
Offline
hou.node(“pathToChildSwitch”)
User Avatar
Member
13 posts
Joined: Oct. 2009
Offline
what I have so far and can't figure out whats wrong is,

result =
for input_node in hou.node(“/wall/switch_tex”).inputs():
result +=
return result

the hou.Node seems to have .inputs but I can't figure out how to point it at the switch. where hou.node(path) seems to give me the node I want but can't figure out how to get the inputs to that node. I found the example in the help documentation but can't seem to modify it correctly.

result =
for input_node in hou.pwd().inputs():
result +=
return result
User Avatar
Member
795 posts
Joined: April 2020
Offline
Please have a look at the attached file, that should work. I think the biggest issue with your code is that you use the node path as a token, while it needs an integer for the input.

Cheers,
Koen

Attachments:
menu.hipnc (48.3 KB)

User Avatar
Member
13 posts
Joined: Oct. 2009
Offline
Thanks for your help, but I still can't figure out how to reference the specific switch in the digital asset. everything I try for the “Path” gives me an error.
the help says that path starts with / but not sure if I can then refer to the node such as /switch_tex or if it needs to be ../switch_tex, or /../switch_tex
Also not sure what function would be best to use. it seems like hou.Node.inputs() would work, but can't figure how to point it at the node I want. please help.

Attachments:
test.otl (28.6 KB)

User Avatar
Member
795 posts
Joined: April 2020
Offline
my houdini crashes when I try to look at your otl.

It sounds like you need to use relative paths. It is very much like a unix filesystem.

Lets say your switch is at “/obj/geo1/wall/swtich1”

and your menu lives on “/obj/geo1/wall”

You can then use hou.pwd() to get a link to /obj/geo1/wall and from then use ./swtch1. For example:


otlNode=hou.pwd()
swtichNode=otlNode.node('./switch')

(or just swtichNode=otlNode.node('switch') )

to use relative paths, use “.” for current and “..” for parent.

Hope that helps.

Koen
User Avatar
Member
13 posts
Joined: Oct. 2009
Offline
Thank you so much for explaining, I couldn't find any real life examples and the help file was just a little to vague. It worked with your example!

choices =

otlNode=hou.pwd()
swtichNode=otlNode.node('./switch_tex')

for index, node in enumerate(swtichNode.inputs()):
choices +=

return choices
User Avatar
Member
13 posts
Joined: Oct. 2009
Offline
So while the menu now works, I have something like 2640 menu's that it has to run the script each time to generate the menu. and it's starting to run slow and I only have about a 3rd of the menu's updated with the script. would It run faster If I had a script on the switch itself that wrote the menu out to a file, and then all the other menu's read the file for the menu contents, or would reading the info from disk be slower? and If I write it to a file how do I make sure that script that writes the file is executed before the ones that reads the file?
  • Quick Links