:-) Like I said, it was just for fun. Obviously I meant to suggest the first one for real use. Its just that, sometimes people don't reply on this group very quickly, so I like to try and have a little fun with the code when I can. You never know, sometimes it might spark ideas. They might think of a new way to use a lambda, or a map, or a list comp, etc. But yea, not that whole crazy one liner, LOL.
On Mon, Apr 2, 2012 at 5:28 PM, Farsheed Ashouri <[email protected] > wrote: > Oh Justin! I almost got a headache when i looked at your lambda recipe.!! > Classic method is better :P > > > On Tuesday, March 27, 2012 9:26:52 PM UTC+4:30, Justin Israel wrote: >> >> 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: >>> python_inside_maya@**googlegroups.com<[email protected]>[mailto: >>> python_inside_maya@**googlegroups.com<[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<http://groups.google.com/group/python_inside_maya> >>> change your subscription settings: http://groups.google.com/** >>> group/python_inside_maya/**subscribe<http://groups.google.com/group/python_inside_maya/subscribe> >>> >>> >>> -- >>> view archives: >>> http://groups.google.com/**group/python_inside_maya<http://groups.google.com/group/python_inside_maya> >>> change your subscription settings: http://groups.google.com/** >>> group/python_inside_maya/**subscribe<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
