wandersonp Posted February 12, 2015 Share Posted February 12, 2015 For example I have a geo1 node and the string in shop_materialpath parm is ../../myShader how can I put this node myShader in a variable with absolute path? my fragment of code is this import hou def printUsedMaterials(): materials = [] for child in hou.node('/').allSubChildren(): for parm in child.parms(): #search in obj node if parm.name() == "shop_materialpath" and parm.eval() != "": materials.append(parm.eval().split("/")[-1]) #search in material node if parm.name() == "shop_materialpath1" and parm.eval() != "": materials.append(parm.eval().split("/")[-1]) print materials printUsedMaterials() Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted February 12, 2015 Share Posted February 12, 2015 # get node node = hou.Node() # get relative path parm = node.parm().eval() # get full path full path = node.node(parm).path() Quote Link to comment Share on other sites More sharing options...
wandersonp Posted February 13, 2015 Author Share Posted February 13, 2015 awesome thanks mantragora the final code with corrections import hou def printUsedMaterials(): materials = [] for child in hou.node('/').allSubChildren(): for parm in child.parms(): #search in obj node if parm.name() == "shop_materialpath" or parm.name() == "shop_materialpath1": path = parm.eval() if path != "": full_path = child.node(path).path() materials.append(full_path) print materials printUsedMaterials() Quote Link to comment Share on other sites More sharing options...
wandersonp Posted February 13, 2015 Author Share Posted February 13, 2015 (edited) I did few modifications in this script, to track which material node is used in scene, the unused materials dont change the colors, them I can track and organize and clean my shops better import hou def getUsedMaterialsPath(): materials = [] for child in hou.node('/').allSubChildren(): for parm in child.parms(): #search in obj node if parm.name() == "shop_materialpath": path = parm.eval() if path != "": full_path = child.node(path).path() materials.append(full_path) return materials def changeColorFromUsedMaterials(color): materials = getUsedMaterialsPath() for material in materials: materialNode = hou.node(material) materialNode.setColor(color) changeColorFromUsedMaterials(hou.Color((1, 0, 0))) Edit: I edited this code coz i need to figure out how to do same thing with the material and shader sops nodes Edited February 13, 2015 by wandersonp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.