Uncategorized

Passing single objects into functions, getting operations on the name string rather than the object itself

Posted by:

When I first started passing single objects into functions and loops I found that python(maya) was treating them as the strings of the object’s name rather than the object itself.

 

This error depends on how the variable of the object is structured.  If it is a single object in a list then you will get this problem.  The solution is to simply encapsulate the variable in a list:

 

[object] Continue Reading →
0

Maya Error Message: Invalid arguments for flag ‘startJoint’. Expected string, got [ unicode ] # Maya, Python

Posted by:

I was working on a function that setup IK handles and I got this error message:

Invalid arguments for flag ‘startJoint’. Expected string, got [ unicode ] #

It turns out that even though the item being passed to the ikHandle() command was not specified as being a list, that is how it was being read.
This may be something peculiar in python, it seems that python may treat anything added to a selection as an array item even if the item is ...

Continue Reading →
0

Maya Error Message: connecting utility node can only concatenate list (not “str”) to list maya, Maya, Python

Posted by:

So, I was writing a function in python for maya and I got this message when trying to connect a utility node to drive a joint’s rotation:

connecting utility node can only concatenate list (not “str”) to list maya

After hours of diagnosing this problem it turns out that if the joint has a null above it, then it queers the connection between the joint and the utility node.
That being said, I was not able to reproduce this issue.  After removing the ...

Continue Reading →
0

Create Null Above Object, Rename Null to Reflect Child Name – Python, Maya

Posted by:

Rename a list of objects using the selection list’s object names in the rename, add a suffix or prefix.

import maya.cmds as cmds

selectionList = cmds.ls( selection=True ) #create a list of object from your current selection

for selectionListObjects in selectionList:

null=cmds.group(empty=True)
nullName = cmds.rename(null, selectionListObjects + ‘Null’)
print newName
cmds.parent(selectionListObjects,nullName)

 

Continue Reading →
0

connectAttr of one selection to another python maya

Posted by:

This takes the 1st selected attribute of an object and connects it to the second object’s attribute:

# HIKConnections
import maya.cmds as cmds

selectionList = cmds.ls( selection=True ) #create a list of object from your current selection

”’connects the first attribute in the function to the second. Note the format of the array then the plus sign then the single quotes and the attribute, interestingly this contains a string as the variable”’
cmds.connectAttr(selectionList[0] + ‘.customVisibility’, selectionList[1] + ‘.visibility’)

 

Continue Reading →
0