How to remove all shaders & create a list of all the image maps used in them?

   1541   2   0
User Avatar
Member
2 posts
Joined: Feb. 2017
Offline
Hello world,
Trying to use hou.find() commands to separate out all the shaders in a hipnc/hdanc file. My goal is to create a list of all the image maps and their locations. So I may then create a convert tool that takes pngs and outputs .rat files to the appropriate locations so none of the paths in the shaders break.

Thanks
User Avatar
Staff
5156 posts
Joined: July 2005
Offline
You can use the opextern hscript expression to see all external file references on a node (eg hou.hscript(“opextern” + node_name)). Then it's just a matter of running that on each shader in the file.
User Avatar
Member
20 posts
Joined: Oct. 2013
Offline
Hi, you could also use something like this in Python, try fo filter for certain extensions

def getFileRef():
    import os.path
    import hou
    refs = hou.fileReferences()
    cleanedRefs = []
    #check all filereferences amd return a list of attributes
    for ref in refs:
        refAsList = []
        if ref[0] != None:
            parm = ref[0]
            fname = parm.eval()
            valid = os.path.isfile(fname)
            fileextension = os.path.splitext(fname)[1]
            refAsList.append(ref[1]) # file reference
            refAsList.append(fileextension) # file extension
            refAsList.append(valid) # file on disk?
            refAsList.append(fname) # resolved path
            refAsList.append(parm.node().name()) #owner
            refAsList.append(ref[0].path()) #parameter name
            cleanedRefs.append(refAsList) parm
    return cleanedRefs

for item in getFileRef():
    print item
  • Quick Links