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
Houdini Multiparm
3927 4 1-
- jjayakumar
- Member
- 106 posts
- Joined: June 2011
- Offline
-
- graham
- 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)))
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
-
- jjayakumar
- Member
- 106 posts
- Joined: June 2011
- Offline
-
- graham
- 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)
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
-
- jjayakumar
- Member
- 106 posts
- Joined: June 2011
- Offline
-
- Quick Links

