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])
prints
pCylinderShape1.vtx[16:17]
pCylinderShape1
skinCluster1
[nt.Joint(u'joint1'), nt.Joint(u'joint2'), nt.Joint(u'joint3'), nt.Joint(u
'joint4')]
[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
>
> http://polycount.com/discussion/140109/melscript-python-selecting-influenced-polygons-from-a-joint
>
> 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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/28060d08-e3e3-43f6-bb4d-40f5713a2456%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to