soho_program and hdaModule

   6204   9   2
User Avatar
Member
380 posts
Joined: 7月 2005
Offline
Messing with SOHO Output Driver from the H11 example…

1) is there a way to set soho_program to a function definition
in the PythonModule of an hda? We're looking to map the logic
presently tied to a fake execute button into this model. Ive tried
various expressions that all seem to lead to the following error.

Error: No soho script program specified for output driver: hou.node(hou.pwd()).hdaModule().hello2().


2) where do soho_program's get picked up from?
when i specify an absolute path for soho_program, such as
/net/homedirs/sdugaro/houdini10.0/scripts/python/Hello2.py
the soho_program runs. When i only specify the basename
i get the following error even though id expect this script to
be available in my houdini path.

Error: No soho script program specified for output driver: Hello2.py.
User Avatar
スタッフ
2592 posts
Joined: 7月 2005
Offline
sdugaro
Messing with SOHO Output Driver from the H11 example…

1) is there a way to set soho_program to a function definition
in the PythonModule of an hda? We're looking to map the logic
presently tied to a fake execute button into this model. Ive tried
various expressions that all seem to lead to the following error.

Error: No soho script program specified for output driver: hou.node(hou.pwd()).hdaModule().hello2().


2) where do soho_program's get picked up from?
when i specify an absolute path for soho_program, such as
/net/homedirs/sdugaro/houdini10.0/scripts/python/Hello2.py
the soho_program runs. When i only specify the basename
i get the following error even though id expect this script to
be available in my houdini path.

Error: No soho script program specified for output driver: Hello2.py.

Hi Steve,

You should be able to specify an opdef: prefix.

If it's not embedded, we search the $HOUDINI_SOHO_PATH for the soho_program in a python%s/ subdirectory (where %s is replaced with the system Python version).

The HOUDINI_SOHO_PATH defaults to $HOUDINI_PATH/soho (but I think you need the pythonX.X sub-directory).

Caveat: This is just by looking at code (no testing).
User Avatar
Member
380 posts
Joined: 7月 2005
Offline
Thanks Mark,

$HOUDINI_SOHO_PATH works as expected.

I'm not exactly sure how to approach the opdef tho.
Say I have a PythonModule section with a def that
specifies what do do when the node is to be ‘rendered’
(this is where the logic tied to the fake execute button
exists)

i get that since the soho_program parameter accepts
a file, an opdef can be used, but how do you point it
to a specific function definition in the PythonModule
section?
User Avatar
Member
17 posts
Joined: 7月 2005
Offline
Did you figure out how to do this without the environment variable?

I think I want to do the same as you in creating a ROP that runs a function from the PythonModule when it's render() function is called.

EDIT: At the moment I just use another button with a callback assigned but doing it properly and having the render function be called would obviously be better.

Help much appreciated,

Thanks,

Stephen
User Avatar
Member
380 posts
Joined: 7月 2005
Offline
No :? im just revisiting this now.
Have you had any luck?

Does anyone have any examples of using soho
with a rop subnet turned hda?
User Avatar
Member
1 posts
Joined: 2月 2010
Offline
Managed to figure it out… You need a param called “soho_program” of type “File”, and set it to something like:
opdef:.?PythonModule
User Avatar
Member
380 posts
Joined: 7月 2005
Offline
Revisiting this in 19.5....

Setting `soho_program=opdef:.?PythonModule` works, however when the Rop is selected or updated, the HDA's PythonModule will be imported.


An invocation function such as render() can be wrapped in a __name__ condition such that it will run as a script and not run when imported as a module. This is done in various SOHO scripts such as HQSim.py, where __name__ gets set to 'HQSim' for instance so render() doesn't fire on module import. Unfortunately, in a PythonModule __name__ is set to 'builtins' regardless of whether its imported or run as a soho_program.

Is there an alternative way around this?

While I could just reference a render script on disk to be picked up in the HOUDINI_SOHO_PATH, I am keen on keeping the render script logic portable with the hda. Perhaps another section in the hda needs to be created and refereced?

tia.
User Avatar
Member
1908 posts
Joined: 11月 2006
Offline
I usually just put the program code (eg. soho_program.py) under "Extra Files" and use that using the previously mentioned opdef:

opdef:Driver/test::1?soho_program.py
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
380 posts
Joined: 7月 2005
Offline
yep. that looks to work.

Create a Custom Script Event Handler, Section Name=render, Add Empty Section, Edit as Python.
Then set `soho_program=opdef:.?render`.

The PythonModule will be imported when the HDA is edited/selected (ie. type properties update),
but the render section python script wont. This will only run when you invoke soho execution
on the rop node... via ropnode.render() for instance.
User Avatar
Member
380 posts
Joined: 7月 2005
Offline
cool, thanks graham. nice to know you are out in the ether.

So for completeness sake, I can create as many python Custom Scripts as I want under the Scripts section of the HDA, such as utils. Then from the render section access the PythonModule code directly (auto imported), and the utils section via createModuleFromSection. Unlike the PythonModule, we don't get kwargs passed through to these custom sections.

So For example, from the render section, with a PythonModule and utils section added to the hda:
import toolutils
node = hou.node('.')
utils = toolutils.createModuleFromSection('utils_module_name', node.type(), 'utils')

def render():
  print("In Render Section")
  node.hdaModule().print_something()
  utils.print_something()

now n.render() on a soho output driver with soho_program=opdef:.?render gets invoked like a script without any event related imports of the PythonModule.
  • Quick Links