Reputation: 21
I am having an error of (Invalid object name: [u'locator1']) when I run my code as show below:
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')
The error seems to show up when I run the last code which is
cmds.aimConstraint(childJoint, selectedJoints[0], aim = (1,0,0), u=(0,1,0), worldUpObject = loc, worldUpType= 'object')
I know, somehow I need to capture the object in order to work, but I quite don't know how to, I am new to python. Any help is greatly appreciated :)
Upvotes: 1
Views: 1905
Reputation: 5895
childJoint = cmds.listRelatives( selectedJoints[0], children = 1 )
Will return a list and you need to pass the index like this
if childJoint:
cmds.aimConstraint(childJoint[0], selectedJoints[0], aim = (1,0,0), u=(0,1,0), worldUpObject = loc, worldUpType= 'object')
Upvotes: 3