And sorry for the spamming, but it seems that V-Ray 3.0 actually does 
register the types for its file attributes.
In Maya 2015 it doesn't list the Alembic attributes, but I assume it will 
with coming version (maybe even Maya 2016)?
Autodesk will likely push developers to register it for their custom nodes 
correctly, this way archive scene also supports it correctly.

Anyway, I just noticed that it's important to perform a refresh before you 
query!
Without doing that I just had it list nothing at all.

Also the filePathEditor command actually 
*does list references!*Here's some better explaining code:

import os

# Refresh the file list cache (note that this is relatively slow for large 
scenes)
cmds.filePathEditor(refresh=True)

# Get the file directories
directories = cmds.filePathEditor(query=True, listDirectories='', 
relativeNames=False)

# Get the files in use
for directory in directories:
    files = cmds.filePathEditor(query=True, listFiles=directory)
    
    # With the file attributes (also see earlier reply with `grouper()` 
function to iterate over it)
    # file_attr = cmds.filePathEditor(query=True, listFiles=directory, 
relativeNames=True, withAttribute=True)
    
    # To get the full path of the files in this directory
    full_paths = [os.path.join(directory, file) for file in files]
    print full_paths

By setting *relativeNames* to *True* it actually returns the unresolved 
paths. Even if a fileName is in the long format in a file attribute and is 
within the current workspace then this command will not resolve it into a 
relative path. It will just read the value as 'raw' from the attribute. Do 
note that sometimes it adds an additional "../" in front of it. 

Hope this helps!

So you should be able to just register missing types temporarily (use the 
tmp flag) and remove them afterwards if you want to include additional 
nodeTypes in solely your query without messing with other settings in the 
current (or next) Maya session.

-Roy


On Wednesday, August 12, 2015 at 10:07:25 AM UTC+2, Roy Nieterau wrote:
>
> For completeness sake. This is how to list unresolved filenames with the 
> file command:
>
> files = cmds.file(query=True, list=True, unresolvedName=True)
>
>
> On Wednesday, August 12, 2015 at 9:12:17 AM UTC+2, Marcus Ottosson wrote:
>>
>> Thanks everyone for your replies!
>>
>> It certainly looks more challenging than I would have thought, the 
>> cmds.file(query=True, 
>> list=True) is close, and the listFiles of filePathEditor almost got it, 
>> and though it looks to work with file nodes, it doesn’t seem to work 
>> with reference nodes, and I wonder what else it won’t work with. Alembic 
>> files probably, as you say, Roy.
>>
>> What’s more, it doesn’t look like reference nodes contain their 
>> unresolved filename, maybe this is resolved by the editor itself?
>>
>> # Always returns a resolved path?
>> cmds.getAttr("ben02_RN.fileNames[0]")
>>
>> The goal of this little experiment is to be able to look at a scene and 
>> determine whether there are any *absolute paths* in it. As in, paths 
>> starting with either a drive letter and a colon (Windows), or a forward 
>> slash (Unix).
>>
>> I’d like to look at a scene with these paths:
>>
>> $ROOT/myfile.mb
>> $OTHERROOT/myotherfile.mb
>> /server/mythirdfile.mb
>>
>> And go “aha, that’s 1 absolute path, and it belongs to node.myAttr”.
>> ​
>>
>

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/78356830-dce9-46ce-b5f9-bda2ae2689f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to