I want to share useful function created by me, I use it in my scripts.
You can modify it in such a way that it will return a pointer to skinCluster for example. I also wrote a some comments. Hope it will be useful for someone.
import maya.OpenMaya as OpenMaya # general Maya API module def isMeshHasSkinCluster(m_objName): """ INPUT: m_objName = '|group2|skinnedMesh' full path to kTransform object stored in scene RETURN: True - if m_objName has any skinCluster, False - otherwise """ m_selectionList = OpenMaya.MSelectionList() # create selectionList m_objPath = OpenMaya.MDagPath() # define MDagPath try: m_selectionList.add(m_objName) # add object to selectionList except: return False # get first element in the selection list and connect with MDagPath m_selectionList.getDagPath(0, m_objPath) # create NULL dagIterator m_dagIterator = OpenMaya.MItDag(OpenMaya.MItDag.kDepthFirst, OpenMaya.MFn.kInvalid) # connect dagIterator with MDagPath m_dagIterator.reset(m_objPath.node(), OpenMaya.MItDag.kDepthFirst, OpenMaya.MFn.kInvalid) while not m_dagIterator.isDone(): # iterate m_objCurr = m_dagIterator.currentItem() # current item if (m_objCurr.hasFn(OpenMaya.MFn.kMesh)): # if current == kMesh # create MObject and connect with current item m_objNameMObj = OpenMaya.MObject(m_objCurr) #print m_dagIterator.fullPathName() # Debug info try: # iterate in m_objNameMObj throw DependencyGraph # based on kSkinClusterFilter m_itDG = OpenMaya.MItDependencyGraph(m_objNameMObj, OpenMaya.MFn.kSkinClusterFilter, OpenMaya.MItDependencyGraph.kUpstream) while not m_itDG.isDone(): m_currentCluster = m_itDG.currentItem() m_fnSkin = OpenMayaAnim.MFnSkinCluster(m_currentCluster) #print m_fnSkin.name() # Debug info return True # SkinCluster exists break except: return False #print 'No skin cluster' m_dagIterator.next() # next item return False