Maya python连接选择的属性 [英] Maya python connect attributes of selection

查看:198
本文介绍了Maya python连接选择的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试制作一个简单的脚本,该脚本将采用2个视口选择,然后基本上将第二个视口的旋转连接到第一个视口,我不确定如何正确地从视口选择中为对象创建变量.这是我的无效尝试

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' )

这篇关于Maya python连接选择的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆