Created
September 11, 2020 01:58
-
-
Save chris-gardner/c9daf34a668c5dddda94b9f6276d8cb8 to your computer and use it in GitHub Desktop.
Load houdini otls / hdas on the fly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
if not os.path.isdir(libPath): print 'library path "%s" does not exist' % libPath
what about using .format instead?