Here is a tightened up version of Mike's cmds approach. It uses sets which
are more efficient and unique by design, and gets rid of the inner for
loop...
texture_types = set(['tif', 'tga', 'png'])
used_files = set()
for file_node in cmds.ls(type='file') :
file_path = cmds.getAttr("%s.fileTextureName" % file_node)
if file_path.lower().rsplit('.', 1)[-1] in texture_types:
used_files.add(file_path)
print used_files
And just for fun, here is a oneliner filter + lambda + generator
texture_types = set(['tif', 'tga', 'png'])
textures = filter(lambda p: p.lower().rsplit('.', 1)[-1] in texture_types,
(cmds.getAttr("%s.ftn" % fNode) for fNode in cmds.ls(type='file')))
--justin
On Tue, Mar 27, 2012 at 9:21 AM, Mike Malinowski (LIONHEAD) <
[email protected]> wrote:
> Using pymel...
>
>
> import pymel.core as pm
>
> texture_types = ['.tga']
> used_files = []
> for file_node in pm.ls(type='file') :
> for texture_type in texture_types :
> file_path = file_node.fileTextureName.get()
> if texture_type in file_path :
> used_files.append(file_path)
> continue
> print used_files
>
>
> or using cmds...
>
> import maya.cmds as cmds
>
> texture_types = ['.tga']
> used_files = []
> for file_node in cmds.ls(type='file') :
> for texture_type in texture_types :
> file_path = cmds.getAttr(file_node + ".fileTextureName")
> if texture_type in file_path :
> used_files.append(file_path)
> continue
> print used_files
>
> -----Original Message-----
> From: [email protected] [mailto:
> [email protected]] On Behalf Of kinjal gajera
> Sent: 27 March 2012 14:14
> To: python_inside_maya
> Subject: [Maya-Python] Re:- Generating texture list by python
>
> Hi TEAM
>
> Please note
> I have one cg maya 2011 file,having various texture.
> my task is to create a script through python,by we can get the complete
> used texture list in maya file.
>
> Expecting positive reply..
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe