def _get_scene_references():
"""
List all the references in the current scene
Return the reference node/attribute and the file path
"""
cmds.filePathEditor(rf=True)
referenced_files: List[Tuple[str, pathlib.Path]] = []
# Get the referenced files from the file path editor
for attribute in cmds.filePathEditor(q=True, lf="", ao=True) or []:
try:
# Skip the nodes that are from an other referenced scene
if cmds.referenceQuery(attribute, isNodeReferenced=True):
continue
except RuntimeError:
continue
# If the attribute is a maya/alembic/... reference
if cmds.nodeType(attribute) == "reference":
file_path = cmds.referenceQuery(
attribute, filename=True, withoutCopyNumber=True
)
referenced_files.append((attribute, pathlib.Path(file_path)))
continue
# Otherwise, just get the attribute for simple stuff like file nodes
file_path = cmds.getAttr(attribute)
# Skip references that have an empty file_path
if len(file_path) == 0:
continue
referenced_files.append((attribute, file_path))
# Make sure to not have duplicates in the references
return list(set(referenced_files))
referenceFiles = _get_scene_references()
print(referenceFiles)
More than 1 year has passed since last update.
python maya filePathEditor get all reference file
Last updated at Posted at 2023-06-28
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme