如何使用python在Maya及其着色器列表连接中查找剃头形状的列表

2024-09-27 23:20:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要打印每个剃须形状和它指定的着色器名称,如果指定。请帮忙。你知道吗

import os
import maya.cmds as cmds
shave_list = cmds.ls(type='shaveHair')
cmds.select(cl=True)
a = 0
list_texture = []
while a < len(shave_list):
    file_list = cmds.listconnections(shave_list[a],type="file")
    a+=1

Tags: import名称osastypelslistfile
1条回答
网友
1楼 · 发布于 2024-09-27 23:20:15

如果需要形状的着色器名称:

def shader_from_shape(shape):
    sg = cmds.listConnections(shape, type='shadingEngine')
    if sg:
        return cmds.listConnections(sg[0]  + ".surfaceShader")

要获取所有头发形状的着色器:

for shape in cmds.ls(type='shaveHair'):
    print shape, shader_from_shape(shape)

如果形状没有附加明暗器,它应该为明暗器打印None。如果形状有多个着色器,这将不会给出正确的结果-我不确定这是否可能。你知道吗

相关问题 更多 >

    热门问题