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!
Return the parameter name on a multiparm parameter (python)?
9931 8 2- grayOlorin
- Member
- 1799 posts
- Joined: 10月 2010
- Offline
- asnowcappedromance
- Member
- 512 posts
- Joined: 7月 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
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
- grayOlorin
- Member
- 1799 posts
- Joined: 10月 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!
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
- mihail.mihno
- Member
- 4 posts
- Joined: 8月 2011
- Offline
- grayOlorin
- Member
- 1799 posts
- Joined: 10月 2010
- Offline
- Rodolphe Coudeyre
- Member
- 3 posts
- Joined: 9月 2014
- Offline
- sdugaro
- Member
- 380 posts
- Joined: 7月 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
with the default value for the expression language set to python.
When your multiparm resolves on your node, that expression should then read
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
I worked around this by writing the default expression like so
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
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_#'))
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('.'), '#')
ie. in my PythonModule I then have
def validate(node,index): parmA = node.parm('multiparmA_%s'%(index)) parmB = node.parm('multiparmB_%s'%(index))
- papsphilip
- Member
- 385 posts
- Joined: 7月 2018
- Offline
grayOlorinCan you provide an example please? i am trying to do the same
Lol thank you its good to know! One of my coworkers asked the same question recently and got the answer!
https://www.sidefx.com/forum/topic/83834/?page=1#post-362461 [www.sidefx.com]
Edited by papsphilip - 2022年4月5日 06:59:30
- papsphilip
- Member
- 385 posts
- Joined: 7月 2018
- Offline
-
- Quick Links