Maya中代理文件的贴图路径获取方案

发布时间:2025-07-07 12:32

转自公号:CGRnDstudio

很实用的一篇文章,在这里推荐给大家。


往往我们拿到一些客户灯光整合文件中存在很多代理文件,比如Arnold的ass文件,Redshift的rs文件,正常来说这些代理文件不会二次赋予材质,材质都是写在代理文件里面的,材质的贴图路径你是看不到的,但是我们又必须check这些贴图是否存在,这里有两段代码,分别获取rs文件和ass文件的所使用到的贴图路径,运行代码很简单,打开Maya,随便导一些ass文件或者rs文件进来,然后在Script Editor中执行下面的Python代码即可获得所有贴图路径(这两段代码来自羊厂长打包王工具里的部分代码),代码到用时方恨少。

获取Redshift渲染器rs代理文件所有贴图路径代码:

import reimport codecsfrom pprint import pprint
import maya.cmds as cmds
def readFileCode_bag2(path):
con = ""
if os.path.exists(path):Arg = codecs.open(path, "r")con = Arg.read()Arg.close()
return con
getAllRs = []getAllNodes = cmds.ls(type="RedshiftProxyMesh")
tm = re.compile("(\\x00\\x00\\x00[A-Za-z]:/.*?\\x00)+")tm2 = re.compile("(\\x00\\x00\\x00//[0-9].*?\\x00)+")
for node in getAllNodes:getPath = cmds.getAttr(node + ".fileName")
if getPath and getPath not in getAllRs:getAllRs.append(getPath)
for oneProxy in getAllRs:getAllPath = []print(oneProxy)getCon = readFileCode_bag2(oneProxy)getResult = tm.findall(getCon)getResult2 = tm2.findall(getCon)
for oneString in getResult:if oneString and "\\" not in oneString and "_map_auto" not in oneString and "/" in oneString:getPathMap = oneString.split("\x00\x00\x00")[1][:-1]if getPathMap and getPathMap not in getAllPath:getAllPath.append(getPathMap)
for oneString in getResult2:if oneString and "\\" not in oneString and "_map_auto" not in oneString and "/" in oneString:getPathMap = oneString.split("\x00\x00\x00")[1][:-1]if getPathMap and getPathMap not in getAllPath:getAllPath.append(getPathMap)
pprint(getAllPath)

获取Arnold渲染器ass代理文件所有贴图路径代码:

from pprint import pprintimport maya.cmds as cmds
import arnold as ar

# 分析ass代理文件贴图路径getAllAss = []getAllNodes = cmds.ls(type="aiStandIn")
for node in getAllNodes:getPath = cmds.getAttr(node + ".dso")
if getPath and getPath not in getAllAss:getAllAss.append(getPath)
for ass in getAllAss:getAllPath = []print(ass)ar.AiBegin()ar.AiMsgSetConsoleFlags(ar.AI_LOG_ALL)ar.AiASSLoad(ass, ar.AI_NODE_ALL)iterator = ar.AiUniverseGetNodeIterator(ar.AI_NODE_ALL)
while not ar.AiNodeIteratorFinished(iterator):node = ar.AiNodeIteratorGetNext(iterator)
if ar.AiNodeIs(node, "MayaFile") or ar.AiNodeIs(node, "image"):getPath = ar.AiNodeGetStr(node, "filename")
if getPath and getPath not in getAllPath:getAllPath.append(getPath)
ar.AiNodeIteratorDestroy(iterator)ar.AiEnd()pprint(getAllPath)

End

特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。

Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.

世界变坏,是从嘲笑项羽开始的!(深度)

世界变坏,是从嘲笑项羽开始的!(深度)

尚曦读史

2025-04-06 20:50:03

一个错误理论,带来的全球悲剧!(上)

一个错误理论,带来的全球悲剧!(上)

古老板的老巢

2025-07-06 11:48:57

她是世界上最危险的女人,也是最快成为首富的女人。

她是世界上最危险的女人,也是最快成为首富的女人。

流苏晚晴

2025-06-29 20:16:50

中年女人为何宁愿在车里,也不想去宾馆?

中年女人为何宁愿在车里,也不想去宾馆?

思絮

2025-07-07 09:07:09

太离谱!日本女生当街小便,朋友还拿梳子采访:爽吗?

太离谱!日本女生当街小便,朋友还拿梳子采访:爽吗?

说点真嘞叭

2025-07-07 04:42:14

网址:Maya中代理文件的贴图路径获取方案 https://mxgxt.com/news/view/1550062

相关内容

干货!Maya动画师如何提高自己的工作效率?
揭秘明星赴美获取绿卡现象:背后原因与实现路径分析
揭秘UI设计:如何从CDR源文件中获取灵感与创意?
社交时代娱乐信息管理的规则路径
基于事理图谱的新冠肺炎疫情网络舆情演化路径分析
杨紫方发布名誉维权案进展 称多起案件依法审理中
“洋网红”传播中华文化的隐序路径
职业经理人的思维路径图
基于事理图谱的网络舆情演化路径分析——以医疗舆情为例
视频文案提取免费软件使用方法,这里有详细步骤!

随便看看