Ok, so the filePathEditor command does allow you to retrieve the attribute 
belonging to a certain file. So I assume it would also allow you to query 
the unresolved path?

from maya import cmds

def grouper(iterable, n, fillvalue=None):
    "Collect data into fixed-length chunks or blocks"
    # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx
    from itertools import izip_longest
    args = [iter(iterable)] * n
    return izip_longest(fillvalue=fillvalue, *args)

files = cmds.filePathEditor(query=True, listDirectories='', withAttribute=
True)
for file in files:
    file_with_attrs = cmds.filePathEditor(query=True, listFiles=file, 
withAttribute=True)
    
    for filepath, attribute in grouper(file_with_attrs, 2):
        attr_value = cmds.getAttr(attribute)
        print attr_value

I remember that originally the filePathEditor got implemented under the 
premise that also plug-in nodes would *tag *there attributes as *filenames* 
so it could always find all files, even for custom nodes. Yet most nodes 
still aren't doing that, eg. Alembic, gpuCache, V-ray proxies. That's 
likely why it has a 'registerType' method now so you can 'try it yourself'.

Another way of listing files used in the scene is the *cmds.file* command. 
That will list references and textures (and probably some others) but won't 
find you the attribute. Probably together with the filePathEditor command 
it might.
The *file* command is also the one used when performing an *Archive Scene* 
with Maya's built-in functionality. (It's a python script in 
Maya/Python/site-packages/maya/app/general/zipScene.py)

According to the code in there it's this line:

    # get a list of all the files associated with the scene
    files = cmds.file(query=1, list=1, withoutCopyNumber=1)

This returns the current scene, note that it will return a non-existing 
scene if the current scene isn't saved. Because it will list 
*{workspace_rootdirectory}/untitled 
*as the first argument.
Though note that it does not find Alembic caches, Yeti fur caches, 
gpuCaches, vray Proxies, etcetera.
I think `cmds.file` allows querying both unresolved and resolved filenames.

Maybe this could also be interesting information: 
http://around-the-corner.typepad.com/adn/2015/06/registering-a-plug-in-to-work-with-maya-archive.html
Yet it seems to be Maya 2016 SP1 only to be fully functional. But at least 
I think it shows Autodesk's intentions.
Probably the Archive Scene command was updated for Maya 2016 SP1 to support 
this, so maybe have a look there to see what commands they use to retrieve 
the file list.

Cheers,
Roy

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/fc324ba3-26b0-4bac-a123-6affbdb15b3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to