如何在Maya中使用Python选择新生成的节点?

如何在Maya中使用Python选择新生成的节点?,python,maya,Python,Maya,我正在尝试创建一个自动复制形状,方法是将一个多边形面包装到另一个多边形形状 # This script wrap a polygon face to the targeted terrain import maya.cmds as cmds # select terrain first, then the face cmds.select( 'terrain', r = True ) cmds.select( 'face', add = True ) # wrapping a polygo

我正在尝试创建一个自动复制形状,方法是将一个多边形面包装到另一个多边形形状

# This script wrap a polygon face to the targeted terrain

import maya.cmds as cmds

# select terrain first, then the face
cmds.select( 'terrain', r = True )
cmds.select( 'face', add = True )

# wrapping a polygon face to the terrain
cmds.transferAttributes( transferPositions = 1 )

# NEW Node transferAttributes1 is created, change its attribute searchMethod to 1.
cmds.setAttr( 'transferAttributes1.searchMethod' , 1 )


# transferAttributes1 is generated after execution of 
# cmds.transferAttributes( transferPositions = 1 ). 
# The name might be different, such as transferAttributes2, transferAttributes3, etc.
# and cmds.setAttr( 'transferAttributes1.searchMethod' , 1 ) might give errors.
我的问题:有没有办法选择新的
transferAttributes
节点并将其传递给
cmds.setAttr()


PS:
transferAttributes*.searchMethod
可能会工作,但它会选择所有
transferAttributes
节点

cmds.transferAttributes
将返回它创建的节点的名称:

cmds.select( 'terrain', r=True )
cmds.select( 'face', add=True )
new_node = cmds.transferAttributes( transferPositions=1 )[0]
cmds.setAttr( new_node +'.searchMethod' , 1 )

cmds.transferAttributes
将返回它创建的节点的名称:

cmds.select( 'terrain', r=True )
cmds.select( 'face', add=True )
new_node = cmds.transferAttributes( transferPositions=1 )[0]
cmds.setAttr( new_node +'.searchMethod' , 1 )

万分感谢!transferAttributes(transferPositions=1)返回字符串列表。新的_节点打印[u'transferAttributes1'],因此cmds.setAttr(新的_节点[0]+'.searchMethod',1)已修复,我从内存中执行了该操作,没有进行检查。谢谢你!transferAttributes(transferPositions=1)返回字符串列表。新的_节点打印[u'transferAttributes1'],因此cmds.setAttr(新的_节点[0]+'.searchMethod',1)已修复,我从内存中执行了该操作,没有进行检查。坦斯克