Hello!
I have a python script inside of a digital asset, I would like to call the script when the user presses a button on the digital asset.
I went to help:
https://www.sidefx.com/docs/houdini/hom/locations.html#asset_events [www.sidefx.com]
when I click on “how to reference embedded files” it goes nowhere ( broken help?)
I can execute a script stored as a parameter using a callback script:
exec hou.node(“.”).evalParm(“test”)
but how would I execute a script stored in the scripts section?
thanks much.
executing a python script inside of a digital asset?
4320 3 0- asmischney
- Member
- 81 posts
- Joined: Aug. 2006
- Offline
- Andr
- Member
- 900 posts
- Joined: Feb. 2016
- Offline
In the script section create a Python Module event handler. Don't change its name, it must stay ‘PythonModule’.
Inside this script you can define and collect a series of function that you can call from the paramer.
In the callbackscript field of your paramater use the following code (rmb to set the language to python):
Inside this script you can define and collect a series of function that you can call from the paramer.
In the callbackscript field of your paramater use the following code (rmb to set the language to python):
hou.phm().yourFunction()
Edited by Andr - March 8, 2019 16:55:16
- Andr
- Member
- 900 posts
- Joined: Feb. 2016
- Offline
it might be handy for you to pass some useful info to your function, for example which parameter is calling the function, or what node is it.
I suggest you to use the kwargs dictionary in your callback
and in your function:
ps. You could also simply pass a single key of the dictionary,
but I wouldn't suggest it to avoid a possible bug [www.sidefx.com]
I suggest you to use the kwargs dictionary in your callback
hou.phm().yourFunction(kwargs)
and in your function:
def myfunction(kwargs): node = kwargs['node'] parm = kwargs['parm']
ps. You could also simply pass a single key of the dictionary,
hou.phm().myFunction(kwargs["parm"])
but I wouldn't suggest it to avoid a possible bug [www.sidefx.com]
Edited by Andr - March 8, 2019 17:03:44
- asmischney
- Member
- 81 posts
- Joined: Aug. 2006
- Offline
Andr
In the script section create a Python Module event handler. Don't change its name, it must stay ‘PythonModule’.
Inside this script you can define and collect a series of function that you can call from the paramer.
In the callbackscript field of your paramater use the following code (rmb to set the language to python):hou.phm().yourFunction()
awesome! thanks so much, that works!
thanks all for the help.
-
- Quick Links