Skip to content

Instantly share code, notes, and snippets.

@vinyvince
Forked from chris-gardner/houdini_otl_hotload.py
Created April 26, 2023 15:56
Show Gist options
  • Save vinyvince/e46dfdc03bd6244908e823cebe7d7831 to your computer and use it in GitHub Desktop.
Save vinyvince/e46dfdc03bd6244908e823cebe7d7831 to your computer and use it in GitHub Desktop.
Load houdini otls / hdas on the fly
import hou
import os.path
def loadHdaLibrary(libPath):
"""
Loads all the HDA files in a folder
@param libPath: HDA library file path
"""
if not os.path.isdir(libPath):
print 'library path "%s" does not exist' % libPath
return
loaded_files = hou.hda.loadedFiles()
# Get all the .otl files in the directory.
filetypes = ['.otl', '.hda']
otl_files = [f for f in os.listdir(libPath) if os.path.splitext(f)[1] in filetypes]
for otl_path in otl_files:
# backslashes are the devils work
full_path = os.path.join(libPath, otl_path).replace('\\', '/')
# If the file isn't already loaded, install it.
if full_path not in loaded_files:
print 'installing', full_path
hou.hda.installFile(full_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment