Hey hey!
I’m trying to create a weighting tool that lets you select 2 verts, hit a button, select another vert, hit a button and it will apply the averaged out influences from the first 2 verts to the last one. But Im running into some problems. Definitely the most advanced tool I’ve tried to write…
First off, I don’t know how to get the mesh data from a selected vert. I need it so I can soft code the skinCluster.
As far as I know, I have to query the cluster (bone of the influence) and the influence percentage seperately and stitch them together since there’s not command that will query all the data at once.
Here’s what Ive been workin on trying to figure it out.
import maya.cmds as cmds
selection = cmds.ls(sl=True, fl=True)
#goes through the verts selected
for sel in selection:
i=0
clusters = cmds.skinPercent('skinCluster1', q=1, t=None)
influencePercentage = cmds.skinPercent('skinCluster1', q=True, v=True)
#Goes through clusters
for cluster in clusters:
influence = influencePercentage[i]
if influence > 0:
infStr = str(influence)
print cluster + '[' +infStr + ']'
i=i+1
I have 3 bones in my scene right now (just testing). I have 1 vert that has influence from 2 of the 3 bones, and when I select the vert and run the script, it prints this out
bone1[0.750080004334]
bone2[0.249919995666]
The data is correct, and it doesnt show the unused influences. But the problem comes when I select 2 verts at a time. I get this error.
Error: RuntimeError: Query point weights only for a single point.
Even though I have it going through my selection in a for loop, which should do it one at a time, no?
So I guess I need help with 3 things.
-How to Query the mesh of a selected vert so that I can soft code the skinCluster, so I can get rid of ‘skinCluster1’. Currently my selection array returns something like this, [u’meshName.vtx[1]']. I need to pull the meshName out and into its own variable.
-Why won’t it work on 2 verts in my current setup?
-What’s the proper output format for influences? Is it bone[.8] or bone.0.8? Im not really sure.
Any help, I would appreciate very very much. Thanks all!