也为组设置属性?

2024-05-17 02:36:02 发布

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

伙计们。我编写了这个简单的脚本来设置所选对象的背面消隐。但我不知道如何将此应用于选定的组?在

import maya.cmds as cmds

sel = cmds.ls(sl = True)
for i in range(len(sel)):
    cmds.setAttr((sel[i] + '.backfaceCulling'), 0)

Tags: 对象inimport脚本trueforlenas
1条回答
网友
1楼 · 发布于 2024-05-17 02:36:02
import maya.cmds as cmds
# dag flag is used to find everything below (like shapes)
# so we specify we want only tansform nodes
sel = cmds.ls(sl = True,  dag=True, type='transform')
for i in sel:
    # we create a string attr for the current object 'i' because we will
    # use it multiple times
    attr = '{0}.backfaceCulling'.format(i)
    # We check if this transform node has an attribute backfaceCulling
    if cmds.ls(attr):
        # if yes, let's set the Attr
        cmds.setAttr(attr, 0)

编辑-多个属性的一个示例:

^{pr2}$

相关问题 更多 >