Maya python connect attributes of selection

徘徊边缘 提交于 2019-12-07 21:26:18

问题


I've been trying to make a simple script that will take 2 viewport selections and then basically connect the rotation of the second to the first, I'm not sure how to create the variables for the objects from the viewport selection correctly. Here is my attempt that is not working

import maya.cmds as cmds
sel = cmds.ls( selection=True, sl=True )
print sel[0]
print sel[0].rotate
print sel[1]
cmds.connectAttr( 'sel[0].rotate', 'sel[1].rotate' )

Any ideas how to make this work?


回答1:


it's just a syntax issue: you're quoting the entire names. You want

cmds.connectAttr( sel[0] + '.rotate', sel[1] + '.rotate' )


来源:https://stackoverflow.com/questions/26288662/maya-python-connect-attributes-of-selection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!