About Me

Not Specified
Not Specified


Recent Forum Posts

How to load different instances of HOU module? July 13, 2020, 10:18 a.m.

Thanks for your help anyway! The resources you linked are definitely helpful, I'll have a deeper read about TOPs.

How to load different instances of HOU module? July 13, 2020, 9:28 a.m.

What would happen if you reloaded hou again after assigning the sphere. Would it clear the assignments from before?
It would still print out data from the sphere_scene, so it doesn't clear anything but instead keeps in memory the latest loaded file.

How are you using this script?
I have extracted the problem from my bigger solution, so at the moment is a simple script which I run this way:
hython myscript.py

What's your particular use-case for having multiple hips in the same script?
The particular use-case is a REST API web server that returns data about a specific scene file based on a given HTTP request.
For example:
GET /api/projects/sphere ==> will return info about sphere_scene
GET /api/projects/box ==> will return info about box_scene
The problem is that I'm trying to reduce the response time, so reloading the scene file for every request just adds a lot of latency.
I work-around that I've thought is to merge all the scenes into a single project file, but doesn't sound ideal since it would be hard to maintain it with a large number of files.

Is there any way you could leverage PDG to have multiple script instances running and sort of work around this issue in a way?
I've never used PDG before, I was just reading something about to figure out how it could solve my issue. It would be great if you could provide an hint/example on how you would solve that with PDG.

Thanks a lot!

How to load different instances of HOU module? July 13, 2020, 6:13 a.m.

Hi there,

I'm importing the hou module into a custom python script and I would like to have multiple scenes opened at the same time. This is how it is implemented:

import sys
from importlib import reload
    import hou
except ImportError:
    print('houdini.py: There was a problem loading the hou module')

box_hip = hou.hipFile
box_scene = box_hip.load(path/to/box_scene.hipnc)
print(box_hip.name()) # ==> box_scene.hipnc CORRECT

sphere_hip = hou.hipFile
sphere_scene = sphere_hip.load(path/to/sphere_scene.hipnc)
print(sphere_hip.name()) # ==> sphere_scene.hipnc CORRECT

# Let's print the name of box_hip again
print(box_hip.name()) # ==> sphere_scene.hipnc WRONG

As you can see, even though I've reloaded the hou module, it's still using the same hou instance for both hip files and therefore always returning the data of the latest loaded scene.

Is there a way to have different instances of the hou module so I can load and work on multiple different hip files in the same script? I've also tried to assign hou to different variables with no luck.

Any help would be highly appreciated, thanks in advance!