PyMel is probably the most straightforward because you can use the API 
command influenceObjects and then read the weightList from an attribute. 
Using the API would be much faster if your rig is complex.
Using cmds...I'm sure someone else knows how to get the influence objects 
from an attr. It's not something I've ever had to do.

Here's a PyMel example. With a couple of verts on a cylinder selected:
import pymel.core as pm
vert = pm.selected()[0]
mesh = vert.node()
sc = mesh.listHistory(type='skinCluster')[0] # Note this is not a great way 
to get skinClusters in general, but it works in simple situations.
infs = sc.influenceObjects()
print vert
print mesh
print sc
vId = vert.currentItemIndex()
print 'Vert:', vId
for jId in xrange(sc.numInfluenceObjects()):
    print '\t', infs[jId], pm.getAttr(sc.weightList[vId].weights[jId])
[nt.Joint(u'joint1'), nt.Joint(u'joint2'), nt.Joint(u'joint3'), nt.Joint(u
[0, 1, 2, 3]
Vert: 16
    joint1 0.0163752022203
    joint2 0.933793770143
    joint3 0.0495594248894
    joint4 0.000271602747264

On Thursday, 12 April 2018 05:23:52 UTC+10, Eugene Flormata wrote:
> does anyone know if it's possible to find a bone from a mesh vertex in 
> python?
> I've found links to code for finding the polygons effected from a bone
> but I'm having trouble finding the right command in reverse
> maybe getting a list of bones affecting one vertex, or the bone with the 
> most weight
> any help would be great 
> thanks!

You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To view this discussion on the web visit
For more options, visit

Reply via email to