[maya][python] findRelatedskinCLuster

a simple newb question…how do I use findRelatedSkinCluster in python?

#want name of skin cluster on  selection
import maya as cmds
selection = cmds.ls(sl=True)
item= selection[0]
print cmds.eval('findRelatedSkinCluster'+item)

esult:

Error: TypeError: Object is invalid

i think your after maya.mel.eval rather than maya.cmds.eval.
(and add a space between the command string and the object)

what Lee said or if you want to traverse to find it you could pymel and make it easy


import pymel.all as pm

jnt = pm.ls(sl=True)[0]
skinCluster = None
for node in jnt.connections():
    if node.nodeType() == 'skinCluster':
        skinCluster = node
        break

thanks! this is what worked:

#want name of skin cluster on  selection
import maya as cmds
selection = cmds.ls(sl=True)
item= selection[0]
print cmds.mel.eval('findRelatedSkinCluster '+item)

I usually import cmds and mel separately. Here’s the way I would have done it (though I don’t know what the “preferred” way is.)

#want name of skin cluster on  selection
import maya.cmds as cmds
import maya.mel as mel
selection = cmds.ls(sl=True)
item= selection[0]
print mel.eval('findRelatedSkinCluster '+item)

On another note, I’m surprised your code isn’t giving an error on the second line. Wouldn’t it have to be the following to work?

selection = cmds.cmds.ls(sl=True)

you’re right. my typo bad.