HOUDINI_OTLSCAN_PATH refresh

   7918   3   0
User Avatar
Member
9 posts
Joined: Dec. 2008
Offline
Hi,

I've been trying to get Houdini to rescan $HOUDINI_OTLSCAN_PATH on-the-fly during runtime, and can't get it to work using Python or HScript. I'm trying to run this from a 456.py script, so that when a user opens a new hipfile, the current shot can be determined and a shot-level OTL directory can be scanned. I've tried doing things like this in my 456.py:

os.environ=“cbin/admin/houd/otls”
hou.hscript( ‘setenv HOUDINI_OTLSCAN_PATH=“cbin/admin/houd/otls”’ )
hou.hscript( “otrefresh” )

Is this impossible? Would I be forced to use a wrapper script instead, so Houdini picks up this variable at initialization? Any guidance would be appreciated.

-James
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
I actually have some functions that do this. One is similar to otrefresh in that it reloads all the installed operators, the other basically goes through all the otl files in HOUDINI_OTLSCAN_PATH and installs any ones that aren't already installed, which seems to be pretty much what you are looking for.

def reloadAllOperators(reload_hfs_operators=False):
“”“ Reload all assets installed in the current session.

reloadhfs_operators: Specify whether or not to reload operator
defintions from the Houdini install directory.
”“”
loaded_files = hou.hda.loadedFiles()

# Reload each file in the loaded files list
for file_path in loaded_files:
# Skip otls in the Houdini install directory unless we specify
# to reload them.
if HOUDINI_OTL_PATH in file_path and not reload_hfs_operators:
continue

hou.hda.reloadFile(file_path)


def rescanOTLPath():
“”“ Rescan the HOUDINI_OTLSCAN_PATH and install any asset definitions
that are not already installed.
”“”

# Get a list of directories in the HOUDINI_OTLSCAN_PATH.
scanned_paths = os.environ.get(“HOUDINI_OTLSCAN_PATH”)

# If the path is set.
if scanned_paths is not None:
# Get the loaded files.
loaded_files = hou.hda.loadedFiles()
# Split the list based on the separating colon.
scanned_paths = scanned_paths.split(':')

for directory_path in scanned_paths:
# Get all the .otl files in the directory.
otl_files = glob.glob(os.path.join(directory_path, “*.otl”))
for otl_path in otl_files:
full_path = os.path.join(directory_path, otl_path)
# If the file isn't already loaded, install it.
if full_path not in loaded_files:
hou.hda.installFile(full_path)
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
7733 posts
Joined: July 2005
Offline
I thought “otrefresh -r” does what rescanOTLPath() does already?
User Avatar
Member
9 posts
Joined: Dec. 2008
Offline
Thanks, Graham! I was trying to avoid doing something like this, but it seems it can't be helped, and upon reflection, it's really not that bad. It's just mimicking, in Python, what Houdini does at startup. Thank you for the code; I'll give it a go.
  • Quick Links