Sunteți pe pagina 1din 2

import hou, os, shutil # The function collect all filles using in scene that matchin a given criteria

# starting with "prefix" and anding with "suffix". def resourceCollector(): collectFolder = hou.parm('./collectFolder').eval() curPath = hou.expandString('$HIP') contlist = ['/obj', '/shop'] parmsEval = [] nodes = [] # Colecting all nodes and his sub childrens in conttext listed in "contList" . for cont in contlist: for nodec in hou.node(cont).allSubChildren(): if not nodec.isLocked(): nodes.append(nodec) prefix = tuple(hou.parm('./prefix').unexpandedString().split(' ')) suffix = tuple(hou.parm('./suffix').unexpandedString().split(' ')) # Creating a new directory for files. if not os.path.isdir(curPath + '/' + collectFolder): os.mkdir(curPath + '/' + collectFolder) # Check all parameter in nodes list and if mach the criteria add it to new l ist. for i in nodes: parms = i.parms() for p in parms: template = p.parmTemplate() if (template.type() == hou.parmTemplateType.String and len(p.keyframes()) == 0) and (p.unexpandedString().endswith( suffix) or p.unexpandedString().startswith(prefix)): parmsEval.append(p.eval()) psplit = os.path.split(p.eval()) newPath = '$HIP' + '/' + collectFolder + '/' + psplit[1] p.set(newPath) # If file do not exist or hasn't same name copy file to a new directory. for i in parmsEval: newPath = curPath + '/' + collectFolder if (not newPath == os.path.split(i)[0] and os.path.isfile(i)): shutil.copy(i, curPath + '/' + collectFolder) print i, '- moved' else: print i, '- File has tha same name or already exist' hou.ui.displayMessage('Done') # Return a list of otl files loaded into this Houdini session. # Look through all the node types, and for those that have digital # asset definitions, remember the otl file containing the definition.

def hdaCollect(): collectFolder = hou.parm('./collectFolder').eval() curPath = hou.expandString('$HIP') prefix = ('C:/PROGRA~1','Embedded') hdaList = [] for category in hou.nodeTypeCategories().values(): for node_type in category.nodeTypes().values(): definition = node_type.definition() if definition is None: continue if definition.libraryFilePath() not in hdaList and not(definition.li braryFilePath().startswith(prefix)): hdaList.append(definition.libraryFilePath()) for i in hdaList: newPath = curPath + '/' + collectFolder fullNewPath = newPath + '/' + os.path.split(i)[1] print fullNewPath, '- fullNewPath' if not(os.path.isfile(fullNewPath)): shutil.copy(i, newPath) print i, '- moved' else: print i, '- File is already exist'

S-ar putea să vă placă și