import maya.OpenMaya as OpenMaya
import maya.OpenMayaAnim as OpenMayaAnim
# oMesh is MObject to your mesh
try:
    itDG = OpenMaya.MItDependencyGraph(oMesh,
OpenMaya.MFn.kSkinClusterFilter, OpenMaya.MItDependencyGraph.kUpstream)
    while not itDG.isDone():
        oCurrentItem = itDG.currentItem()
        fnSkin = OpenMayaAnim.MFnSkinCluster(oCurrentItem)

        # Don't need to loop any more since we got the skin cluster
        break

except:
    # No skin cluster
    pass




On Thu, Oct 8, 2009 at 8:23 AM, Paul Molodowitch <elron...@gmail.com> wrote:

>
> Here's the code I used to accomplish that task in PM_heatWeight:
>
> def isATypeOf(node, type):
>    """Returns true if node is of the given type, or inherits from it."""
>    if isinstance(node, basestring) and cmds.objExists(node):
>        return type in cmds.nodeType(node, inherited=True)
>    else:
>        return False
>
> def listForNone( res ):
>    if res is None:
>        return []
>    return res
>
> def getSkinClusters(mesh):
>    """
>    Returns a list of skinClusters attached the given mesh.
>    """
>    return [x for x in listForNone(cmds.listHistory(mesh))
>            if isATypeOf(x, 'skinCluster')]
>
>
> Obviously, not all api, but the only call that I don't know of any
> easy API conversion for is listHistory.  I think in order to get an
> equivalent result, you have to trace back through connections to
> 'inMesh' (or equivalent if you're not using a poly mesh), and check
> for nodes that have their 'isHistoricallyInteresting' attribute set...
> but I'm not positive.
>
> Be interested to hear what others do for this...
>
> - Paul
>
> On Thu, Oct 8, 2009 at 7:57 AM, bhar...@irrigger.com
> <i.r.rig...@gmail.com> wrote:
> >
> > if there is a way to grab a hold of information relating to mesh such
> > as skin clusters using API. I know in python I could simply eval the
> > findRelatedSkinCluster or grab all the skinClusters in the scene and
> > then work backwards from there. But I'm trying to work exclusively
> > through API at the moment and would love to find a way to start with a
> > selected mesh and grab information for it. thanks!!
> >
> > Brandon L. Harris
> >
> > >
> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to