Skip to content

Instantly share code, notes, and snippets.

@chris-gardner
Created September 11, 2020 01:58
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save chris-gardner/c9daf34a668c5dddda94b9f6276d8cb8 to your computer and use it in GitHub Desktop.
Save chris-gardner/c9daf34a668c5dddda94b9f6276d8cb8 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)
@legomir
Copy link

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