How to get all paths inside maya file?

2,038 views
Skip to first unread message

Mahmoodreza Aarabi

unread,
Oct 8, 2016, 9:13:51 AM10/8/16
to Python Programming for Autodesk Maya
Hello Masters

I want to get all file paths inside maya, it is possible to get each type of path separately, like textures, references, cache files, scenepath, but i want get all exisisting paths quickly.

do you think there is any way?
any idea?

Thanks in advance.

Marcus Ottosson

unread,
Oct 8, 2016, 10:59:09 AM10/8/16
to python_in...@googlegroups.com

Paths are independent for each node, so there isn’t a global method to fetch all of them; particularly not ones specified in non built-in nodes, like from a plug-in developed by your studio. They’re just arbitrary string attributes, some of which happen to be used to point to a directory on disk.

But if you know the node types you are interested in getting paths from - and odds are you do if you operate within a studio with a fixed set of nodes used to reference nodes - then you can simply list all nodes, e.g. cmds.ls(type="AlembicNode"), and read the path attribute of each individually.

Also have a look at the File Path Manager, under Window -> General Editor -> File Path Manager for how Maya does this with some if not all of its built in nodes. It’ll give you a listing of all paths (that it knows of) used in the current session. But again, it won’t list paths in string attributes from nodes it doesn’t know about, so it’s not 100% accurate.

Then there is the Archive feature in Maya, which must do something similar, but again, can never be 100% accurate.

Fredrik Averpil

unread,
Oct 9, 2016, 2:11:27 AM10/9/16
to python_in...@googlegroups.com
Like Marcus said, there's no universal way to do this, unfortunately.

Another approach worth mentioning is to detect filepaths by using Maya ASCII scene file format and parsing that.

You can also iterate over all attributes of all objects in a scene and detect filepaths, although this can be slow on complex scenes.

Regex it's one way to detect a filepath but "if filepath.startswith(y)" and "if x in filepath" are faster approaches.

// F

Nicolas Chaverou

unread,
Oct 11, 2016, 9:38:20 AM10/11/16
to python_in...@googlegroups.com
What about filePathEditor ?
Maya native nodes all register their file-type attributes within the File Path Editor to be able to use the File Path Editor

If most 3rd party vendors do the same (we do), that unifies the process pretty much
For those who don't, you can still fetch their custom nodes using Fred approach maybe

Here's the command:
filePathEditor -query -listRegisteredTypes

Best,


--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWPa%2BdzJQC_3E6XB%3DHPA-Dr%2BxaJQjExjby_UF%3DLf01qUjg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages