Maya“无效对象类型”

时间:2015-11-20 02:08:57

标签: python maya

当我运行我的代码时出现错误(无效的对象名称:[u'locator1']),如下所示:

loc = cmds.spaceLocator()
selectedJoints = cmds.ls(sl=True)
childJoint = cmds.listRelatives( selectedJoints[0], children = 1 )
cmds.aimConstraint(childJoint, selectedJoints[0], aim = (1,0,0), u=(0,1,0), worldUpObject = loc, worldUpType= 'object')

当我运行最后一个

代码时,错误似乎出现了
cmds.aimConstraint(childJoint, selectedJoints[0], aim = (1,0,0), u=(0,1,0), worldUpObject = loc, worldUpType= 'object')

我知道,不知怎的,我需要捕获对象以便工作,但我完全不知道如何,我是python的新手。非常感谢任何帮助:)

1 个答案:

答案 0 :(得分:2)

childJoint = cmds.listRelatives( selectedJoints[0], children = 1 )

将返回一个列表,您需要像这样传递索引

if childJoint:
    cmds.aimConstraint(childJoint[0], selectedJoints[0], aim = (1,0,0), u=(0,1,0), worldUpObject = loc, worldUpType= 'object')