hi ynedlin ,
you can use a couple of API_commands , to get to the skinweights (
should be "much faster" - i made myself a simlpe skinCLuster
import-export plugin that way , and compared to "mel-commands" or
"python.cmds" it is really fast ( approx. 40times faster than mel ) ,
but about 2 or 3 times slower than in C++ )
so i post you the "way" i used python to "get the information" from the
maya_API .
then ... while looping through the vertecies , you can find out , if a
joint has a skinweight above a certain value , and then , write the
vertex-number into an array .
// ----------------- start
import maya.OpenMaya as om
import maya.OpenMayaAnim as omAnim
# this will give you the skinweights for "skinCluster1"
skin = 'skinCluster1'
selectionList = om.MSelectionList()
selectionList.add( skin )
node = om.MObject()
selectionList.getDependNode( 0, node )
skinClusterNode = omAnim.MFnSkinCluster(node)
# get the number of influences that affect the skinCluster
infs = om.MDagPathArray()
numInfs = skinClusterNode.influenceObjects(infs)
# get dagPath for the skinCluster at index 0
skinPath = om.MDagPath()
index = 0
skinClusterNode.indexForOutputConnection(index)
skinClusterNode.getPathAtIndex(index,skinPath)
# iterate through all vertecies
geom = om.MItGeometry(skinPath)
vertecies = geom.count()
# here is a list , of all the joint-names and influence objects , inside
the skinCluster
jointNames = []
for counter in range(0,numInfs,1):
infName = infs[counter].partialPathName()
jointNames.append(infName)
print (jointNames)
# here come the weights ( you need to define a maya_API_DoubleArray
wts = om.MDoubleArray()
# now you need to create a MScriptUtil
infCount = om.MScriptUtil()
ccc = infCount.asUintPtr()
# so ccc is the kind of "Unsigned integer" , that i need later for the
skinCluster.getWeights()
# this might be a bit weird to understand , and i dont really understand
it by myself , but it works
# ccc will be the "influenceCount" - that the .getWeight returns
# ok , lets go on
component = om.MObject()
# next is a LOOP ( all vertecies )
# e.g. for getting the pointPosition in worldspace
# not needed , just an example
while ( not geom.isDone()):
point = om.MPoint()
point = geom.position(om.MSpace.kWorld)
# for each vertex , get its component-information
component = geom.component()
# get skinWeights
# needed is the skinCluster_path , output will be an array of weights (
wgts ) for the given "component"
skinClusterNode.getWeights(skinPath,component,wts,ccc)
# print the WTS ( round them , and if they are Zero write '0' instead
of '0.000'
for i in range(0,len(wts),1):
print (wts[i])
geom.next()
// ----------------- end
hope this helps you a bit ...
maybe , these lines of python can be shortened and maybe some lines of
code , can be left out ( i am not a very good programmer ) - but it was
working well for my purpose
have a nice day
sim.On
ynedelin schrieb: