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?
解决方案
it's just a syntax issue: you're quoting the entire names. You want
cmds.connectAttr( sel[0] + '.rotate', sel[1] + '.rotate' )