maya是否可以列出文件中使用的所有外部资产,例如纹理或其他被引用的场景?
理想情况下,这将使用python完成。我对3ds max比较熟悉,所以我不确定maya是否具有3ds max的等效值,您可以通过以下方式完成此操作...
收集类类型texturemap的所有资产,返回文件路径。然后收集类型类型为xref的所有资产,它返回引用的场景和那个它!
答案 0 :(得分:2)
您可以在场景中列出所有引用的纹理,然后使用:cmds.ls(“REF_NAME:*”,type =“file”)
查询所有引用:cmds.file(q = 1,r = 1)
--- --- EDIT 我有时间写一个完整的代码示例:
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))