List all images in file


#1

Is there a way using python to list all the images being used in a maya file?

Whether it’s on a shader or anything else.
Thanks


#2

Yes. From within maya simply do a:

import pymel.core as pm
textureNodes = pm.ls(type="file")

If you need the name:

for t in textureNodes:
	print t.textureFileName.get()

From extern it is a little bit more complicated. To be flexible, you can use mayapy from commandline, open a file and do the same as above.


#3

Great!
Thank you.
I did what you said, but why does this error when i run it? It says the
textureFileName.get() # AttributeError: ‘unicode’ object has no attribute ‘textureFileName’.


import maya.cmds as cmds

# list maya textures
_textures = cmds.ls(type="file")
print "
"
for t in _textures:
	print t
	print t.textureFileName.get()


#4

Like in haggi’s example, you need to use pymel to take advantage of all the useful object oriented methods.
Is there some reason you went back to cmds ?

David