Pymel, skinPercent, transform query doesn't work!

Hi all,

This code works in Mel correctly:

string $shoot[] = skinPercent -q -t "skinCluster2" "nurbsToPoly1.vtx[20]" ;

But it doesn’t work in Pymel:

shoot = pm.skinPercent( “skinCluster2”, “nurbsToPoly1.vtx[20]”, t=True, q=True )

Error: RuntimeError: Found 0 matches for ‘True’.

What am I doing wrong?

Thanks,

By the way changing the order of argument as mentioned in docs doesn’t work neither

shoot = pm.skinPercent( “skinCluster2”, “nurbsToPoly1.vtx[20]”, q=True, t=True )

you have to pass the name of influence object you want to query as the transform arg, like t=‘joint2’. I have had issues with this too, in fact in order to get a list of influence items that was specific to the selected verts I had to use mel cause I couldn’t get pymel or cmds modules to give me anything but the list of all influence transforms on the skin cluster

from the docs:


# Get the weight of vtx[100] corresponding to joint1
#
cmds.skinPercent( 'skinCluster1', 'pPlane1.vtx[100]', transform='joint1', query=True )

[QUOTE=mattanimation;16575]you have to pass the name of influence object you want to query as the transform arg, like t=‘joint2’. I have had issues with this too, in fact in order to get a list of influence items that was specific to the selected verts I had to use mel cause I couldn’t get pymel or cmds modules to give me anything but the list of all influence transforms on the skin cluster

from the docs:


# Get the weight of vtx[100] corresponding to joint1
#
cmds.skinPercent( 'skinCluster1', 'pPlane1.vtx[100]', transform='joint1', query=True )

[/QUOTE]

Thanks Matt, but what if we want to find the joints that affect a particular vertex?

I needed to find all joints and their weight on a skinCluster, which I already found a work around. But, I still really want to know how to translate such Mel script to python:

string $shoot[] = skinPercent -q -t "skinCluster2" "nurbsToPoly1.vtx[20]" ;

This really appears to be a bug of some sort. Here’s a forum thread complaining about the same problem: http://forums.cgsociety.org/archive/index.php/t-525082.html

I guess I’d suggest a hack workaround:


import pymel.core as pm

oObj = pm.selected()[0] # start by selecting the geometry with the skinCluster.

influences = []
try: oColl = pm.skinCluster(oObj, query=True, influence=True)
except: print "Exception: it doesn't appear to have a skinCluster."
for each in oColl:
	shoot = mc.skinPercent( "skinCluster1", "pSphere1.vtx[20]", transform=each.name(), q=True )
	if shoot > 0:
		influences.append(each)
print influences

here’s what I did:


inf_jnts = []  #joints of influence
list_of_names = maya.mel('skinPercent "skinCluster1" -q -t;')   #those joints as a unicode string list
for n in list_of_names:
    inf_jnts.append(pm.PyNode(n))   #make strings pyNodes

running the code as mel works even though it doesn’t as python or pymel but you can still get pyNodes from it. This DOES return the list of ONLY transforms that are influencing the selected vertices.