Maya / Python,如何更改显示图层的颜色?

时间:2018-02-24 17:22:43

标签: python colors maya layer display

创建新的显示图层后,如何将颜色属性设置为该图层?

sel = cmds.ls(selection=True,fl=True)    
coneGroup = cmds.group(empty=True,name="cones_#")
dGroup = cmds.createDisplayLayer(coneGroup, n = "cones_cam")
cmds.color(dGroup, (0,0,0))

3 个答案:

答案 0 :(得分:2)

使用需要使用setAttr

sel = cmds.ls(selection=True,fl=True)    
coneGroup = cmds.group(empty=True,name="cones_#")
dGroup = cmds.createDisplayLayer(coneGroup, n = "cones_cam")

# Enable the layer's color.
cmds.setAttr("{}.color".format(dGroup), True)

# Enable the layer's color to use rgb.
cmds.setAttr("{}.overrideRGBColors".format(dGroup), True)

# Set the layer's color with values between 0-1.
cmds.setAttr("{}.overrideColorRGB".format(dGroup), 1, 0, 0)

答案 1 :(得分:0)

代码摘录:

for shadingEngine in cmds.ls(type="shadingEngine"):
    new_shader = cmds.listConnections(shadingEngine, type = 'lambert')[0]
    print new_shader
    new_sg = mC.sets(renderable=True, noSurfaceShader=True, empty=True)
    print new_sg
    f=mC.setAttr (new_shader+'.color',values[0],values[1],values[2])

    mC.hyperShade(assign=new_shader)

上面的代码适用于通过您可以引用的曲面节点进行颜色着色并暗示它为H。

答案 2 :(得分:0)

#code

对于cmds.ls(type =“ shadingEngine”)中的shadingEngine:

    new_shader = cmds.listConnections(shadingEngine, type = 'lambert')[0]
    print new_shader
    new_sg = mC.sets(renderable=True, noSurfaceShader=True, empty=True)
    print new_sg
    f=mC.setAttr (new_shader+'.color',values[0],values[1],values[2])
    mC.hyperShade(assign=new_shader)

上面的代码通过您可以引用并暗示的表面节点上的颜色阴影进行工作,为您的搜索感到高兴