Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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)
@legomir

This comment has been minimized.

Copy link

@legomir legomir commented Sep 11, 2020

if not os.path.isdir(libPath): print 'library path "%s" does not exist' % libPath

what about using .format instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.