I’m looking for a way to list all nodes that somehow reference an external file; be it references, textures, or some obscure custom node with an attribute for paths.
I was looking at the cmds.filePathEditor which is close.
>>> cmds.filePathEditor(query=True, listDirectories="")
[list of paths]
But it doesn’t show me which nodes are responsible for these paths, and doesn’t show me the full filenames.
Any ideas?
Also, importantly, I’d like their unresolved entry, no the resolve one. The command above only returns resolved paths.
# Right
$ROOT/parent/file.mb
# Wrong
/server/projects/myproject/parent/file.mb
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOA8yE2SWch_%3D-_jAG-uEUY6r52CA3tYg%3D00hDnb8REjEg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CADrk2uQHWZ-wseM4haxmC4x7Wa2EzrSFt2Hbik-KUXnHdQU4qA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CADrk2uQHWZ-wseM4haxmC4x7Wa2EzrSFt2Hbik-KUXnHdQU4qA%40mail.gmail.com.
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a0cfa12a-90cb-4890-8e3f-6b46cfc34ffd%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBgtVoNmxD1XOCNbFu3jrkShgYx5ro_ePL1-uKL7-C%2Bfw%40mail.gmail.com.
import pymel.core as pm # GET A LIST OF REFERENCES refs = pm.listReferences() # LOOP THROUGH AND PRINT THE PATH # for ref in refs: # PATH print("path: %s"% ref.path) # NAMESPACE print("namespace: %s" % ref.namespace)
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1ebbe8ae-aada-4a31-8e71-2eddd8f02e93%40googlegroups.com.
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
# get a list of all the files associated with the scene
files = cmds.file(query=1, list=1, withoutCopyNumber=1)
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”.
files = cmds.file(query=True, list=True, unresolvedName=True)
cmds.file(query=True, list=True, unresolvedName=True)
I think that’s it!
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/232e4654-4676-4c5e-9ca6-35feb1d63bd3%40googlegroups.com.
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
--
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_m...@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.
validate all filepaths before publishing.
You’re absolutely right.
As I’m not alone in solving it, here’s some more research.
I’ve found that if I temporarily export an .ma
of nodes, excluding those that I know won’t have one and may be heavy to export (such as mesh
), I can parse the resulting ASCII file for /
. The file ends up light, regardless of how “heavy” a scene is, and takes under a few milliseconds to export.
The /
in the file is used for either:
Excluding comments, the rest results to all paths present in the scene.
Though I haven’t tested it thoroughly, I’d expect to run into the need for additional parsing for:
/
/
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWMxNTmWZO7zMw%3DBkgumcf8C5cKrJv1Vg-0Ky3VaVW2mKQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBR%3DmaE_bcj2OLZffjfzEO-7FtUYU5VZ2%3DDAQV1SzTQGw%40mail.gmail.com.
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/78356830-dce9-46ce-b5f9-bda2ae2689f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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%3DwhWMxNTmWZO7zMw%3DBkgumcf8C5cKrJv1Vg-0Ky3VaVW2mKQ%40mail.gmail.com.--
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.
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/471b115e-6e9e-4a3b-bdf1-4ca0dc2d44b0%40googlegroups.com.
Oh, that's an interesting note, thanks for sharing Sivanny.So, how would one access the path from a reference node? Is the information not stored in the node at all? Where is it stored?
On 12 August 2015 at 17:27, Sivanny Selvakumar <sivanny.s...@gmail.com> wrote:
Hi Marcus,--Just a quick note about the fileNames attribute. It's actually obsolete and hasn't been used since Maya 6.0. It was only kept around for backwards compatibility. After Maya 6.5, reference paths are only accessible via the referenceQuery and the file command. Other attributes that are not used anymore include connectionList, setAttrList, addAttrList, deleteAttrList, brokenConnectionList, parentList, edits and multiParentList. placeHolderList is still used, though. It looks like the node docs don't really state this, but they totally should!Just FYI,Sivanny
On Wednesday, August 12, 2015 at 12:12:17 AM UTC-7, Marcus Ottosson wrote: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]")
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/471b115e-6e9e-4a3b-bdf1-4ca0dc2d44b0%40googlegroups.com.