列出maya中的所有外部资产

List all external assets in maya

在 Maya 中是否可以列出文件中使用的所有外部资源,例如纹理或引用的其他场景?

理想情况下,这将使用 python 完成。我对 3ds max 比较熟悉,所以我不确定 maya 是否具有 3ds​​ max 的等效项,您可以通过以下方式简单地执行此操作...

收集 class 类型纹理贴图的所有资产,其中 returns 文件路径。然后收集 class 类型外部参照的所有资产,其中 returns 引用了场景,仅此而已!

您可以列出场景中所有引用的纹理,然后使用:cmds.ls("REF_NAME:*", type="file")

查询所有参考文献:cmds.file(q=1,r=1)

---编辑--- 我有时间写一个完整的代码示例:

import maya.cmds as cmds
import glob

files = cmds.ls(type=["file", "imagePlane"])
result = []
for i in files:
    if cmds.objectType(i) == "file":
        #animated ?
        testAnimated = cmds.getAttr("{0}.useFrameExtension".format(i))
        if testAnimated:
            # Find the path
            fullpath= cmds.getAttr("{0}.fileTextureName".format(i))

            # Replace /path/img.padding.ext by /path/img.*.ext
            image = fullpath.split("/")[-1]
            imagePattern = image.split(".")
            imagePattern[1] = "*"
            imagePattern = ".".join(imagePattern)

            # You could have done a REGEX with re module with a pattern name.padding.ext
            # We join the path with \ in order to be Linux/Windows/Apple format
            folderPath = "\".join(fullpath.split("/")[:-1] + [imagePattern])

            # Find all image on disk
            result+=(glob.glob(folderPath))
        else:
            result.append(cmds.getAttr("{0}.fileTextureName".format(i)))
    elif cmds.objectType(i) == "imagePlane":
        #animated ?
        testAnimated = cmds.getAttr("{0}.useFrameExtension".format(i))
        if testAnimated:
            # Find the path
            fullpath= cmds.getAttr("{0}.imageName".format(i))
            # Replace /path/img.padding.ext by /path/img.*.ext
            image = fullpath.split("/")[-1]
            imagePattern = image.split(".")
            imagePattern[1] = "*"
            imagePattern = ".".join(imagePattern)

            # You could have done a REGEX with re module with a pattern name.padding.ext
            # We join the path with \ in order to be Linux/Windows/Apple format
            folderPath = "\".join(fullpath.split("/")[:-1] + [imagePattern])

            # Find all image on disk
            result+=(glob.glob(folderPath))
        else:
            result.append(cmds.getAttr("{0}.imageName".format(i)))
#clear multiple instance
result = list(set(result))