getElements from MFnSingleIndexedComponent

Hey guys
I do not use OpenMaya very often so I need an advise here. I am writing a few functions to deal with skin weights and all works great as long as I do not change the components. I would like to change components for the setWeights.

Right now I create the variables I need and then run the MFnSkinCluster.getWeights.

So it looks sort of like this:

apiComponents = om.MFnSingleIndexedComponent().create(om.MFn.kMeshVertComponent)
skinCluster = omAnim.MFnSkinCluster(om.MObject())

skinCluster.getWeights(
skinPath,
apiComponents,
weights,
influenceCount)

Good!

Now I would like to know what is inside the apiComponents, and hopefully change it. I assume this is MFnSingleIndexedComponent object, therefore I should be able to run something like

vertexIndexList = om.MIntArray()
apiComponents.getElements(vertexIndexList)

But I get this error

self.apiComponents.getElements(vertexIndexList)

File “c:\buildforge\Maya_2013_Win64\build\work\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py”, line 1529, in <lambda>

File “c:\buildforge\Maya_2013_Win64\build\work\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py”, line 54, in _swig_getattr

AttributeError: getElements

please shed some light on how this supposed to work .

thank you

Yury

“getWeights” is expecting you to give it the components that are having weights queried. It doesn’t return components to you.

To get the components you can either get the get components from MSelectionList, or take a look at this example (which is where you seem to be headed already):

http://ewertb.soundlinker.com/api/api.025.php