Return the parameter name on a multiparm parameter (python)?

   9496   8   2
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
How do I go about returning the parameter name of a multiparm attribute? I am trying to use this for a menu script that is supposed to populate a menu based off the choice of a multiparm parameter. just using hou.parm(“myObject/parm_#”) does not work. I also tried using hou.parm(“.”) to see if I could return the current parameter but to no avail.

Any help on this would be hugely appreciated!

thanks!
-G
User Avatar
Member
512 posts
Joined: July 2009
Offline
If I understand you correctly, you have a menu button with multiple choices that you want to have access to?
If you have a rollout menu with 3 buttons for example, you can do the following:

parm = hou.node(“/obj/yournode”).evalParm(“yourparm”)

Depending on what choice you made in the rollout, parm will return you either the number 0,1 or 2.

Now you can do an if statement:


if parm == 0:
populate your node #1
else:
if parm == 1:
populate #2
else:
populate #3


I hope I could help you,

Manu
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Hey asnowcappedromance,

Thank you for your reply. What I am actually looking for is the parameter value of a parameter inside of a multi parm folder via a menu script. Say I have two parameters called

Parm_source_#
Parm_dest_#

If you put those parameters in a multi parm folder, for every iteration of that block, houdini creates the following parameters:

Parm_source_1
Parm_dest_1
Parm_source_2
Parm_dest_2
Etc…

The issue here is that Parm_dest_# is a drop down menu procedurally generated by a menu script that needs to reference the value of The corresponding Parm_source_#. However, I do not know how to get the value inside of Parm_source_# because I do not know how to set the parameter name in my python script to use the returned value of #. using # in my python script does not seem to be valid, so I am wondering if there is an alternative

Thanks!
-G
User Avatar
Member
4 posts
Joined: Aug. 2011
Offline
I think my answer will not be “just in time”
But maybe for someone else it can be useful.

To get multiparm instance from Menu Script, you can use kwargs
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Lol thank you its good to know! One of my coworkers asked the same question recently and got the answer!
-G
User Avatar
Member
3 posts
Joined: Sept. 2014
Offline
Hi there,

I have a question about events on the folder multiparm.
How can I catch delete item event or clear all event?

I meet difficulties to find nformation about this. Thanks !
R.
User Avatar
Member
380 posts
Joined: July 2005
Offline
Just tried something similar.
I think what you are looking for is something like this:

In the defaults of your parameter Template, you would put something like
hou.phm().validate(hou.node('.').evalParm('multiparm_#'))
with the default value for the expression language set to python.

When your multiparm resolves on your node, that expression should then read
hou.phm().validate(hou.node('.').evalParm('multiparm_1'))
hou.phm().validate(hou.node('.').evalParm('multiparm_2'))
hou.phm().validate(hou.node('.').evalParm('multiparm_3'))

I did notice that (at least in 16.0.705) that you cant do this twice…
ie. the expression parser doesn't seem to like multiple #'s and will fail to resolve
hou.phm().validate(hou.node('.').evalParm('multiparmA_#'),hou.node('.').evalParm('multiparmB_#'))

I worked around this by writing the default expression like so
hou.phm().validate(hou.node('.'), '#')
such that when it resolves I have a node instance on which to lookup multiple template parameters using the resolved multiparm index number.
ie. in my PythonModule I then have

def validate(node,index):
  parmA = node.parm('multiparmA_%s'%(index))
  parmB = node.parm('multiparmB_%s'%(index))
User Avatar
Member
385 posts
Joined: July 2018
Offline
grayOlorin
Lol thank you its good to know! One of my coworkers asked the same question recently and got the answer!
Can you provide an example please? i am trying to do the same

https://www.sidefx.com/forum/topic/83834/?page=1#post-362461 [www.sidefx.com]
Edited by papsphilip - April 5, 2022 06:59:30
User Avatar
Member
385 posts
Joined: July 2018
Offline
i think i found the solution, for anyone interested.

Attachments:
menu_scipt_get_multiparm_instance.hiplc (86.9 KB)

  • Quick Links