Jump to content

How to load different instances of HOU module?


leota90

Recommended Posts

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
sys.path.append(HOUDINI_PATH)
try:
    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

reload(hou)
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!

 

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...