PyMel- Getting texture file from a material
So, my first inelegant-yet-functional PyMel script is done and working. The core of it is in this little snippet here, that digs through a mesh's inputs until it finds the texture node on the surface shader: #Pass through the mesh's shape and return a texture name. import pymel as pm def getTextureFile(geo): sg = [] #Get the shading group from the selected mesh raw_sg = pm.listConnections(geo, type='shadingEngine') #Rapidly check for duplicates in the list- I do this by checking each item #against an empty list. #If the item is not in the empty list I append it. for element in raw_sg: if element not in sg: sg.append(element) #Get some info sgInfo = pm.listConnections(sg[0], type='materialInfo') fileNode = pm.listConnections(sgInfo[0], type='file') textureFile = pm.getAttr(fileNode[0].fileTextureName) print 'This is the file', str(textureFile) return str(textureFile) It st...