当我运行我的代码时出现错误(无效的对象名称:[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的新手。非常感谢任何帮助:)
答案 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')