我正在编写一个python脚本,将场景输出到一个简单易读的文件中。在
我已经成功地输出了位置、旋转、缩放和网格名称,但是如何获得应用于网格的纹理的文件名呢?在
import maya.cmds as cmds
meshesWithoutShape = []
meshes = cmds.ls("mesh_*")
for mesh in meshes:
if("Shape" not in mesh):
meshesWithoutShape.append(mesh)
shapesInSel = cmds.ls(dag=1,o=1,s=1)
shadingGrps = cmds.listConnections(shapesInSel,type='shadingEngine')
shaders = cmds.ls(cmds.listConnections(shadingGrps),materials=1)
fileNode = cmds.listConnections('%s.color' % (shaders[0]), type='file')
currentFile = cmds.getAttr("%s.fileTextureName" % fileNode[0])
for mesh in meshesWithoutShape:
print("\n" + mesh.rstrip('1234567890'))
print round(cmds.getAttr("%s.translateX" % mesh), 2), round(cmds.getAttr("%s.translateY" % mesh), 2), round(cmds.getAttr("%s.translateZ" % mesh), 2)
print cmds.getAttr("%s.rotateX" % mesh), cmds.getAttr("%s.rotateY" % mesh), cmds.getAttr("%s.rotateZ" % mesh)
print cmds.getAttr("%s.scaleX" % mesh), cmds.getAttr("%s.scaleY" % mesh), cmds.getAttr("%s.scaleZ" % mesh)
fileNode = cmds.listConnections('%s.color' % (shaders[0]), type='file')
currentFile = cmds.getAttr("%s.fileTextureName" % fileNode[0])
print currentFile
你可以用ls列出所有的文件节点并得到纹理路径?在
如果要从选择或特定网格获取
^{pr2}$更新
这里是你想要处理你的需求的代码
相关问题 更多 >
编程相关推荐