Hello,
How can I use the callback script of an hda to run a hscript script saved in the scripts section? If it lets you type a custom hscript there, surely there must be a way to use it? If you are wondering why I am not using python, its because I plan to use opscript command to print a huge list of commands that I need to execute to re-build a network/certain parameters. that is also why I want to save the script under lists. Its easy to edit a bigger scripts there then on the callback script section which is just one line. I have seen plenty of info on how to do that in python, but how can I do this in hscript?
Thanks
Callback script and hscript
2492 8 2-
- evanrudefx
- Member
- 266 posts
- Joined: Feb. 2016
- Offline
-
- vikus
- Member
- 247 posts
- Joined: May 2017
- Offline
-
- evanrudefx
- Member
- 266 posts
- Joined: Feb. 2016
- Offline
-
- evanrudefx
- Member
- 266 posts
- Joined: Feb. 2016
- Offline
-
- vikus
- Member
- 247 posts
- Joined: May 2017
- Offline
evanrudefx
I was wondering, how can I do the same thing in python? I switched from hscript to python, so of course that doesn't work anymore.
Hey, in python:
hou.phm().foo()
foo() is any function from your HDA Python module. Simply select the PythonModule in HDA under Scripts and define a function:
def foo(): print('hello')
You can also define your function in the Session Module and then call your callback like this:
hou.session.foo()
Edited by vikus - Nov. 10, 2023 16:36:00
-
- evanrudefx
- Member
- 266 posts
- Joined: Feb. 2016
- Offline
viklci'll be honest, I don't really don't know what I am doing. But in this case that won't work. I am trying to do something that accesses
def foo():
print('hello')
kwargs["node"]
kwargs["node"]
Edited by evanrudefx - Nov. 10, 2023 16:42:54
Thanks,
Evan
Evan
-
- vikus
- Member
- 247 posts
- Joined: May 2017
- Offline
-
- evanrudefx
- Member
- 266 posts
- Joined: Feb. 2016
- Offline
viklcThanks so much. Amazing. I got it working.
The python module kwargs dictionary only passes the node type. You can test this simply by calling print(kwargs). If you need the reference to the current node in the python module, use:instead ofnode = hou.pwd()node = kwargs['node']
Edited by evanrudefx - Nov. 10, 2023 17:10:43
Thanks,
Evan
Evan
-
- vikus
- Member
- 247 posts
- Joined: May 2017
- Offline
-
- Quick Links
