Houdini Multiparm

   3927   4   1
User Avatar
Member
106 posts
Joined: June 2011
Offline
Hey
I'm having a multiparm with two parameters, a string field and a button. whenever the user presses the button, I'm running a script that takes the string as an argument to the function defined in the python module. If I hard code the value_# as value_1 it works. But I want in such a way that if button 2 is clicked, it should pass stringname_2 as argument. How do I do this? Any help is highly appreciated.

Thanks
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
You'll want to use some sort of pattern matching/regex/whatever to figure out what parm was pressed based on the name of the parm that the callback is occurring from.

For example, given a parm name like “button_3” being pressed, to get the # out of it you could do this.
instance = re.match(“button_(\d+)”, parm_name).group(1)
You could then be like
myfunc(node.evalParm(“string_{0}”.format(instance)))
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
106 posts
Joined: June 2011
Offline
Thanks for your reply. But I'm still not able to get it to work. What is parm_name in the match function ? I believe it is the parameter name of the button being pressed. How do I get that ?
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
You'll need to add some intermediary function, or roll something like this into your current function.

This function would be called by the button's callback script and located in the PythonModule:
hou.phm().buttonPress(kwargs)
Code in the PythonModule:
def buttonPress(scriptargs):
node = scriptargs
parm = scriptargs

parm_name = parm.name()

instance = re.match(“button_(\d+)”, parm_name).group(1)
str_value = node.evalParm(“string_{0}”.format(instance))
# The function you want to call that takes a string value.
myfunc(str_value)
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
106 posts
Joined: June 2011
Offline
Hey Graham

Thank you so much. I got it to work. I'm new to Houdini and I'm still figuring out how things work. I'm really glad that your answer fixed my problem. Hope this helps others also.

Thanks again!
  • Quick Links